#1112126 cproto: implies it runs /lib/cpp(?), actually runs gcc -E by default

Package:
cproto
Source:
cproto
Description:
utilities to generate C function prototypes from C source code
Submitter:
наб
Date:
2025-09-02 01:35:02 UTC
Severity:
normal
Tags:
#1112126#5
Date:
2025-08-26 17:07:57 UTC
From:
To:
Dear Maintainer,

I'm trying to work around some explosive source code (src:tgif 1:4.2.5-2)
with something like
  cproto -E 'cpp' -D'ARGS_DECL(...)=__VA_ARGS__' -{P,F,C}"int f(a, b)" -a exec.c

Quoth cproto(1):
  -E cpp Pipe the input files through the specified C preprocessor command
         when generating prototypes.  By default, the program uses /lib/cpp.
  -E 0   Do not run the C preprocessor.

This doesn't appear to hold at all. /lib/cpp isn't a valid preprocessor,
but even supplying -E cpp or -E /bin/cpp I see no preprocessing happen
(and don't see an execve() in strace at all).

It looks like -E working at all is guarded on #ifdef CPP?
It would be nice, for future readers, to say "-E ... ignored",
if this is intended.

Best,

#1112126#10
Date:
2025-08-26 17:18:49 UTC
From:
To:
Okay, nevermind that, apparently the preprocessor only runs without -a; however:
  $ strace -fe execve  cproto -D'ARGS_DECL(...)=__VA_ARGS__' -{P,F,C}"int f(a, b)" exec.c
  execve("/bin/cproto", ["cproto", "-DARGS_DECL(...)=__VA_ARGS__", "-Pint f(a, b)", "-Fint f(a, b)", "-Cint f(a, b)", "exec.c"], 0x7fff563a9f98 /* 32 vars */) = 0
  strace: Process 3089145 attached
  [pid 3089145] execve("/bin/sh", ["sh", "-c", "gcc -E -DARGS_DECL(...)=__VA_ARG"...], 0x7ffd5d411a90 /* 32 vars */) = 0
  /* exec.c */
  sh: 1: Syntax error: "(" unexpected
  [pid 3089145] +++ exited with 2 +++
  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3089145, si_uid=1000, si_status=2, si_utime=0, si_stime=0} ---
  +++ exited with 0 +++
so, it runs gcc -E.

One'd certainly think it ought run "${CC-cc} -E", but whatever.
It's definitely not running /lib/cpp!

#1112126#19
Date:
2025-08-26 22:46:07 UTC
From:
To:
...actually the manpage could be improved, to show the actual compiled-in
default.

cproto's using popen.

(I agree, it should re-escape/re-quote parameters -- it seems that noone's
recently bit on this).

these two lines are unclear

#1112126#22
Date:
2025-08-26 22:46:07 UTC
From:
To:
...actually the manpage could be improved, to show the actual compiled-in
default.

cproto's using popen.

(I agree, it should re-escape/re-quote parameters -- it seems that noone's
recently bit on this).

these two lines are unclear

#1112126#27
Date:
2025-08-27 14:00:04 UTC
From:
To:
I was confused by -a disabling the preprocessor,
so I overfit "cproto -a is not running cpp"
to "Debian cproto has cpp/-E disabled altogether".

In spite of my poor report you hit on both points I was trying to drive at.

Thanks,

#1112126#32
Date:
2025-09-01 15:38:39 UTC
From:
To:
I don't see that in the package's debian/rules file.

In following up on the issue with the manpage,
I have this (in my test package):

       -E cpp Pipe the input files through the specified C  preprocessor  com‐
              mand  when  generating prototypes.  By default, the program uses
              “x86_64-linux-gnu-gcc -E” via a pipe.

#1112126#37
Date:
2025-09-01 16:43:23 UTC
From:
To:
Actually, it does quote parameters.  The problem is the -a option,
which isn't readily addressed.  If cproto is told to use the -a or -t
options, it works only for the unpreprocessed source.  But since
cproto has only a very limited ability to handle preprocess-related
stuff, it cannot find the header files, nor can it expand macros by
itself.

I'll document this in the manpage.

#1112126#42
Date:
2025-09-01 16:48:29 UTC
From:
To:
The manpage does say this:

BUGS
...
       The program does not pipe the source files through the  C  preprocessor
       when  it is converting function definitions.  Instead, it tries to han‐
       dle preprocessor directives and macros itself and can  be  confused  by
       tricky macro expansions.  The conversion also discards some comments in
       the function definition head.

so I'll try to improve the explanation.

#1112126#45
Date:
2025-09-01 16:48:29 UTC
From:
To:
The manpage does say this:

BUGS
...
       The program does not pipe the source files through the  C  preprocessor
       when  it is converting function definitions.  Instead, it tries to han‐
       dle preprocessor directives and macros itself and can  be  confused  by
       tricky macro expansions.  The conversion also discards some comments in
       the function definition head.

so I'll try to improve the explanation.

#1112126#48
Date:
2025-09-01 16:43:23 UTC
From:
To:
Actually, it does quote parameters.  The problem is the -a option,
which isn't readily addressed.  If cproto is told to use the -a or -t
options, it works only for the unpreprocessed source.  But since
cproto has only a very limited ability to handle preprocess-related
stuff, it cannot find the header files, nor can it expand macros by
itself.

I'll document this in the manpage.

#1112126#53
Date:
2025-09-02 01:33:50 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
cproto, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1112126@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Kenneth J. Pronovici <pronovic@debian.org> (supplier of updated cproto package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Tue, 02 Sep 2025 00:47:47 +0000
Source: cproto
Architecture: source
Version: 4.7y-1
Distribution: unstable
Urgency: medium
Maintainer: Kenneth J. Pronovici <pronovic@debian.org>
Changed-By: Kenneth J. Pronovici <pronovic@debian.org>
Closes: 1112126
Changes:
 cproto (4.7y-1) unstable; urgency=medium
 .
   * New upstream release.
     - Improve manpage discussion of limitations when using cproto's built-in
       support for C preprocessor directives (closes: #1112126)
   * Bump standards version to 4.7.2.0 (no packaging changes).
   * Update debian/copyright to reflect latest upstream dates and license text.
Checksums-Sha1:
 c8a5f632758e71b9f1c20c52756ff7027dddf5aa 1888 cproto_4.7y-1.dsc
 11711240a31f20c3dcce39645104f298fe675c7f 197318 cproto_4.7y.orig.tar.gz
 53492cad9d9b55f1d52fcd08ed84a00656f87b0a 8664 cproto_4.7y-1.debian.tar.xz
 649c75fb394a7ece7cd086d29a205e57454d8d67 6111 cproto_4.7y-1_amd64.buildinfo
Checksums-Sha256:
 deacc9acec10f25e8fd03b1acf487c56d7309c12b3694e17ed1b06a51b7da1bc 1888 cproto_4.7y-1.dsc
 0bd1d8be8ff0a4ca43f947f95750d34f64eda93c9e2ca79100fd60140b7c6331 197318 cproto_4.7y.orig.tar.gz
 0cc769742c3f736ddb6a77e2bed65cf87f1caca75d7f7ee5f65b545e57cf1a7e 8664 cproto_4.7y-1.debian.tar.xz
 641abe36de76a9ef08931f625fdb40adf62571a919831d93acfe91de31aa0542 6111 cproto_4.7y-1_amd64.buildinfo
Files:
 13af92ce4b121fff3b56713b2623fac5 1888 devel optional cproto_4.7y-1.dsc
 1b34bb5bbad7e8dd035abe4145b6b9e1 197318 devel optional cproto_4.7y.orig.tar.gz
 add2050f857163e2b7444c508519c2f7 8664 devel optional cproto_4.7y-1.debian.tar.xz
 0b6771b26ca008b8c4e654a4f560369c 6111 devel optional cproto_4.7y-1_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEECkY/XOB9CXm1xckHERkoku/XWTQFAmi2Qq4ACgkQERkoku/X
WTTqEw/+LeB5FGITXg/gsftIctgYpeuF8sG5jwxKI8nVaUqtFsbxoXZwRJQq+Dfh
LcN7z/QIvzVvjOWGsCHEJEvwsTuLes+YTzSJGALkiTorNqmr2RZNcU2aFWTq5WCl
+FdYSArriJDoP6zCKcjZMF9q8kiCdZU+ur4wvpv07GXQJlsbSoZj7xAZQ2WegMA+
tZ7FAEGr1Wwa+vXdGM6d0HPpme3eDcpE4hXYRRwLwsCORvKO4pWuuuhkYrPo01K6
2fn+GSVYgzFVM/DKfbBDYO3JYRAus7WwHJNFjdDJXA+QvDRTDRGZM8E7AddwZOd4
WmX3QG5lKF9T4okskbMH5RIlvMNPPkDHtY5tWuhEo6nuLEqkkS6QU1nER09M1lr2
48NJfGOfbVXXUfp0ptd1TXYXvwyvx+VCSA+YU/INH+DAcDqG22WCSwLtldtKwwHb
7q4y1Y/1fwJO15IA31ETJb5zm7cGxCCcHBd3r5TZ9cCA3xE7NKl1xj/lfBZvSHfo
YKwQg07eOpet5kDE9pV9rHI3RTmjTFLTqXX6u3s3+ya9twLIv/FQPFRNOKMOZHmI
QGMomCT/j8l00x022XsezEjL6PT919ALwGnsAJMhLyOjJuTl/uVPlseXyejVNSEb
J4NUV7hqTg1QnD19fXJvy71yNwixVGqNa6X5VjmWBBq6pHTsRmY=
=aadH
-----END PGP SIGNATURE-----