#1112128 cproto: doesn't understand real/valid C code (tgif 1:4.2.5-2 exec.c), in -a mode only?

Package:
cproto
Source:
cproto
Description:
utilities to generate C function prototypes from C source code
Submitter:
наб
Date:
2025-09-02 15:31:03 UTC
Severity:
normal
Tags:
#1112128#5
Date:
2025-08-26 18:37:56 UTC
From:
To:
Dear Maintainer,

If you dget src:tgif 1:4.2.5-2 and run
  cproto -{P,F,C}"int f(a, b)" exec.c
you'll get a dump of the prototypes.

If you run
  cproto -a -{P,F,C}"int f(a, b)" exec.c
you'll instead get a lot of output,
/some/ prototypes changed,
but that output ends with
  exec.c:10428: syntax error at token ''
with the transformation edge at
-- >8 --
int PipeReachedEOF(FILE *fp)
{
   if (feof(fp)) return TRUE;

   /* this works because of non-blocking I/O */
   while (getc(fp) != EOF) ;
#ifdef EAGAIN
   if (errno == EINPROGRESS || errno == EAGAIN) {
#else /* ~EAGAIN */
   if (errno == EINPROGRESS) {
#endif /* EAGAIN */
      /* do nothing */
      return FALSE;
   }
   /* a real EOF */
   return TRUE;
}

int WaitForEvent(fp, fp_is_pipe, fp_is_named_pipe, pn_quit,
      what_to_do_with_x_events, pf_abort_callback, p_void)
   FILE *fp;
   int fp_is_pipe, fp_is_named_pipe, *pn_quit, what_to_do_with_x_events;
   AbortCallbackFunc *pf_abort_callback;
   void *p_void;
   /*
    * returns TRUE if there's character waiting in fp
    *
    * This routine is not really general purpose because characters can
    *       swallowed in the PipeReachedEOF() routine.
    * So if for any reason the content of the pipe is required, don't
    *       use this function!
    * fp_is_pipe is TRUE if fp is opened with popen().  This is not the
    *       same as a named pipe.
    * fp_is_named_pipe is TRUE if fp is a named pipe (S_IFIFO).
    */
{
   int rc=FALSE;

   *pn_quit = FALSE;
-- >8 --

exec.c starts by having 10427 lines,
so the error occurs one-past-the-end of that?

The compiler understands the code before and after the transformation
(so long as K&R declarations are allowed, of course).

Best,

#1112128#10
Date:
2025-08-26 18:41:38 UTC
From:
To:
The full error is actually
  exec.c:10428: syntax error at token ''
  Expected: }
so this makes sense.

#1112128#13
Date:
2025-09-01 19:57:22 UTC
From:
To:
agreed - it's not going to work.  The updated manpage says

       The program does not pipe the source files through the  C  preprocessor
       when  it is converting function definitions (i.e., options -a, -b, -t).
       That is because cproto does the conversion by replacing strings, rather
       than by converting to/from lexical tokens.  Instead of using the C pre‐
       processor, cproto tries to handle preprocessor  directives  and  macros
       itself,  to  find type definitions.  There are several limitations as a
       result:

       •   the search-path for included files contains only “/usr/include” and
           the directories listed by “-I” options.

       •   conditional directives (e.g., “#if”) are ignored.

       •   only macros without parameters are handled.

       •   some comments in the function definition head are discarded.

#1112128#18
Date:
2025-09-01 19:57:22 UTC
From:
To:
agreed - it's not going to work.  The updated manpage says

       The program does not pipe the source files through the  C  preprocessor
       when  it is converting function definitions (i.e., options -a, -b, -t).
       That is because cproto does the conversion by replacing strings, rather
       than by converting to/from lexical tokens.  Instead of using the C pre‐
       processor, cproto tries to handle preprocessor  directives  and  macros
       itself,  to  find type definitions.  There are several limitations as a
       result:

       •   the search-path for included files contains only “/usr/include” and
           the directories listed by “-I” options.

       •   conditional directives (e.g., “#if”) are ignored.

       •   only macros without parameters are handled.

       •   some comments in the function definition head are discarded.

#1112128#23
Date:
2025-09-02 15:28:56 UTC
From:
To:
Version: 4.7y-1
I've reviewed the 4.7y-1 manual, and I think if I had it while doing the
tgif conversion I would not have felt the need to have opened the bugs,
which is equivalent to being fixed. Thus, closing; thanks.
Nor do I think this would be a good use of anyone's time, frankly.

Best,