How to find out which .c file contains the .c functions of R internals, on Windows?

后端 未结 4 406
南方客
南方客 2020-12-10 03:06

I want to view the source code of R\'s match.call function. As it is an internal function, I downloaded the R source code, went to ./src/main/names.c and looked

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 03:58

    Uwe Ligges wrote an "R Help Desk" article on this very topic in R News (2006, 6(4):43-45).

    Once you've identified the actual C function that is used, then use your filesystem search tools to search for the function name in the relevant source folder; in this case ./src/main/, e.g. on Linux

    $ grep -r -H "do_matchcall" ./src/main/
    ./src/main/.svn/text-base/names.c.svn-base:{"match.call",   do_matchcall,   0,  11, 3,  {PP_FUNCALL, PREC_FN,   0}},
    ./src/main/.svn/text-base/unique.c.svn-base:SEXP attribute_hidden do_matchcall(SEXP call, SEXP op, SEXP args, SEXP env)
    ./src/main/unique.c:SEXP attribute_hidden do_matchcall(SEXP call, SEXP op, SEXP args, SEXP env)
    ./src/main/names.c:{"match.call",   do_matchcall,   0,  11, 3,  {PP_FUNCALL, PREC_FN,   0}},
    

    indicating that unique.c is the place to look in this case.

    To the best of my knowledge, there is no way (other than invoking a system call to the terminal) to identify from within R which source file contains the C code for a given function in R - well, not without rewriting grep or find or similar using R code :-)

提交回复
热议问题