in reply to Re^3: Checking the include form and getting only the header name
in thread Checking the include form and getting only the header name

Sometimes there are comments at the end,so that scenario also needs to be takin into account

/files/src/services/usb_dcd/private/internals.h:#include "queue.h" /*c +omments*/

Replies are listed 'Best First'.
Re^5: Checking the include form and getting only the header name
by Eliya (Vicar) on Mar 20, 2011 at 01:50 UTC

    The second option I posted (i.e. cutting off the stuff before #include) takes care of that.

    Otherwise, if you don't want the comments in the output, simply remove the $ (which means "anchor at end of line") in the first option.

      I noticed the below condition fails for the below input.Basically anything inside " " and <> should match except a space,how can we change the below match for this?

      INPUT:- #include <io-pkt/iopkt_driver.h> --> should match #include "string.h " -->should not match #include "devnp-msm-ipc.h" -->should match if ($line =~ /#include [<"](\w+\.h)[>"]/)

        That's basically what we had in the beginning, except that you probably want \S+ (non-whitespace), or maybe \S.* (if there could be spaces within the file name), in place of \w+:

        if ($line =~ /#include [<"](\S+\.h)[>"]/)

        P.S. "string.h " shouldn't match anyway, because (\w+\.h)[>"] doesn't allow a space between .h and ".