]> mj.ucw.cz Git - libucw.git/commitdiff
API: Introduced exceptions for common mistakes of the symbol mapper
authorMartin Mares <mj@ucw.cz>
Tue, 28 Jan 2014 16:02:42 +0000 (17:02 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 28 Jan 2014 16:02:42 +0000 (17:02 +0100)
tools/map-symbols
ucw/lib.h
ucw/string.h

index bb82a9468eded3eba5f43a15ec227d7d2a550439..94d3016dafc309938d3e9111b7beccb9ca813a39 100755 (executable)
@@ -4,12 +4,24 @@
 
 use common::sense;
 
+sub symbol {
+       my ($sym) = @_;
+       return if $sym =~ m{^(ucw|ucwlib)_};
+       print "$sym\n";
+}
+
 sub parse {
        my ($file) = @_;
        print "# $file\n";
        open my $f, '<', $file or die;
        while (<$f>) {
                chomp;
+               # Interpret special comments
+               m{// NOAPI} and next;
+               if (m{// API: (\w+)}) {
+                       print "$1\n";
+                       next;
+               }
                # Find things which look like top-level declarations
                s{//.*}{};
                s{/\*.*}{};
@@ -32,9 +44,9 @@ sub parse {
                if (m{^extern [^,]*(\s+\**\w+(,\s+\**\w+)*);}) {
                        my $x = $1;
                        $x =~ s{[,*]}{}g;
-                       print join("\n", grep { !/^$/ } split /\s+/, $x), "\n";
+                       symbol $_ for grep { !/^$/ } split /\s+/, $x;
                } elsif (m{( |\*)(\w+)\(}) {
-                       print "$2\n";
+                       symbol($2);
                } else {
                        print "??? $_\n";
                }
index 302f19ed447ae2c7b3dac37c3dda44b7336b4e71..9892d9723e7c5946a1b37cdae81bd1255b01ab2d 100644 (file)
--- a/ucw/lib.h
+++ b/ucw/lib.h
@@ -155,7 +155,7 @@ void vdie(const char *fmt, va_list args) NONRET;            /** va_list version of die() *
 
 extern char *log_title;                        /** An optional log message title. Set to program name by log_init(). **/
 extern int log_pid;                    /** An optional PID printed in each log message. Set to 0 if it shouldn't be logged. **/
-extern void (*log_die_hook)(void);     /** An optional function called just before die() exists. **/
+extern void (*log_die_hook)(void);     /** An optional function called just before die() exists. **/   // API: log_die_hook
 
 void log_init(const char *argv0);      /** Set @log_title to the program name extracted from @argv[0]. **/
 void log_fork(void);                   /** Call after fork() to update @log_pid. **/
index 8122b1cf5a9e80b1015de4df856337920580a175..0c64ace57dca303d8f3e6e447fc09cec03b931b0 100644 (file)
@@ -30,7 +30,7 @@
 /* string.c */
 
 #ifdef CONFIG_DARWIN
-uns strnlen(const char *str, uns n);
+uns strnlen(const char *str, uns n);   // NOAPI
 #endif
 
 /**