[patch, cosmetic] bb_mkdep
Bernhard Fischer
rep.nop at aon.at
Tue Sep 13 21:46:16 UTC 2005
Hi vodz [I'm not sure if you got my earlier mail, so retrying here],
Attached are some minor cosmetic spelling corrections in comments.
I added a more descriptive help text too.
Please apply if you think it is nice.
PS: I did *not* add a line with a license such as
* Licensed under the GPL v2, see the file LICENSE in this tarball.
Please do this or add the standard BSD blob or the like.
cheers,
Bernhard
-------------- next part --------------
diff -X excl -ruNp busybox.which.oorig/scripts/bb_mkdep.c busybox.which/scripts/bb_mkdep.c
--- busybox.which.oorig/scripts/bb_mkdep.c 2005-09-13 19:15:19.000000000 +0200
+++ busybox.which/scripts/bb_mkdep.c 2005-09-13 20:12:32.000000000 +0200
@@ -1,31 +1,37 @@
/*
- * Another dependences for Makefile fast mashine generator
+ * Another fast dependencies generator for Makefiles
*
* Copyright (C) 2005 by Vladimir Oleynik <dzo at simtreas.ru>
*
- * This programm do
+ * This program does:
* 1) find #define KEY VALUE or #undef KEY from include/config.h
* 2) save include/config/key*.h if changed after previous usage
- * 3) recursive scan from "./" *.[ch] files, but skip scan include/config/...
+ * 3) recursive scan from "./" *.[ch] files, but skips scan of include/config/
* 4) find #include "*.h" and KEYs using, if not as #define and #undef
- * 5) generate depend to stdout
+ * 5) generate dependencies to stdout
* path/file.o: include/config/key*.h found_include_*.h
* path/inc.h: include/config/key*.h found_included_include_*.h
- * This programm do not generate dependences for #include <...>
- *
- * Options:
- * -I local_include_path (include`s paths, default: LOCAL_INCLUDE_PATH)
- * -d (don`t generate depend)
- * -w (show warning if include files not found)
- * -k include/config (default: INCLUDE_CONFIG_PATH)
- * -c include/config.h (configs, default: INCLUDE_CONFIG_KEYS_PATH)
- * dirs_for_scan (default ".")
-*/
+ * This programm does not generate dependencies for #include <...>
+ */
#define LOCAL_INCLUDE_PATH "include"
#define INCLUDE_CONFIG_PATH LOCAL_INCLUDE_PATH"/config"
#define INCLUDE_CONFIG_KEYS_PATH LOCAL_INCLUDE_PATH"/config.h"
+#define bb_mkdep_full_options \
+"\nOptions:" \
+"\n\t-I local_include_path include paths, default: \"" LOCAL_INCLUDE_PATH "\"" \
+"\n\t-d don't generate depend" \
+"\n\t-w show warning if include files not found" \
+"\n\t-k include/config default: \"" INCLUDE_CONFIG_PATH "\"" \
+"\n\t-c include/config.h configs, default: \"" INCLUDE_CONFIG_KEYS_PATH "\"" \
+"\n\tdirs_to_scan default \".\""
+
+#define bb_mkdep_terse_options "Usage: [-I local_include_paths] [-dw] " \
+ "[-k path_for_stored_keys]"/* [-s skip_file]*/" [dirs]"
+
+
+
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
@@ -40,6 +46,7 @@
#include <errno.h>
#include <fcntl.h>
+
typedef struct BB_KEYS {
char *keyname;
const char *value;
@@ -54,7 +61,7 @@ typedef struct FILE_LIST {
long size;
} file_list_t;
-/* partial and simplify libbb routine */
+/* partial and simplified libbb routine */
static void bb_error_d(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
static char * bb_asprint(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
@@ -69,14 +76,14 @@ static void *xmalloc(size_t size);
static char *bb_xstrdup(const char *s);
static char *bb_simplify_path(const char *path);
-/* for lexical analyzier */
+/* for lexical analyser */
static bb_key_t *key_top;
static llist_t *configs;
static void parse_inc(const char *include, const char *fname);
static void parse_conf_opt(char *opt, const char *val, size_t rsz);
-/* for speed triks */
+/* for speed tricks */
static char first_chars[257]; /* + L_EOF */
static int pagesizem1;
@@ -86,6 +93,9 @@ static char *id_s;
static bb_key_t *check_key(bb_key_t *k, const char *nk);
static bb_key_t *make_new_key(bb_key_t *k, const char *nk);
+/* error messages */
+static char *msg_enomem = "memory exhausted";
+
#define yy_error_d(s) bb_error_d("%s:%d hmm, %s", fname, line, s)
/* state */
@@ -95,9 +105,9 @@ static bb_key_t *make_new_key(bb_key_t *
#define REM '/' /* block comment */
#define BS '\\' /* back slash */
#define POUND '#' /* # */
-#define I 'i' /* #include preprocessor`s directive */
-#define D 'd' /* #define preprocessor`s directive */
-#define U 'u' /* #undef preprocessor`s directive */
+#define I 'i' /* #include preprocessor's directive */
+#define D 'd' /* #define preprocessor's directive */
+#define U 'u' /* #undef preprocessor's directive */
#define LI 'I' /* #include "... */
#define DK 'K' /* #define KEY... (config mode) */
#define DV 'V' /* #define KEY "VALUE or #define KEY 'VALUE */
@@ -117,7 +127,7 @@ static bb_key_t *make_new_key(bb_key_t *
id = xrealloc(id, local_mema_id += 16); \
id[id_len++] = c; } while(0)
-/* stupid C lexical analizator */
+/* stupid C lexical analyser */
static void c_lex(const char *fname, long fsize)
{
int c = L_EOF; /* stupid initialize */
@@ -271,7 +281,7 @@ static void c_lex(const char *fname, lon
for(;;) {
/* <STR,CHR>\n|<<EOF>> */
if(c == '\n' || c == L_EOF)
- yy_error_d("unterminating");
+ yy_error_d("unterminated");
if(c == BS) {
/* <STR,CHR>\\ */
getc1();
@@ -310,7 +320,7 @@ static void c_lex(const char *fname, lon
/* <#.*>/ */
getc1();
if(c == REM)
- yy_error_d("detect // in preprocessor line");
+ yy_error_d("detected // in preprocessor line");
if(c == '*') {
/* <#.*>[/][*] */
called = state;
@@ -370,7 +380,7 @@ static void c_lex(const char *fname, lon
getc1();
}
if(!id_len)
- yy_error_d("expected identificator");
+ yy_error_d("expected identifier");
put_id(0);
if(state == U) {
parse_conf_opt(id, NULL, (optr - start));
@@ -409,8 +419,7 @@ static void c_lex(const char *fname, lon
static void show_usage(void) __attribute__ ((noreturn));
static void show_usage(void)
{
- bb_error_d("Usage: [-I local_include_paths] [-dw] "
- "[-k path_for_store_keys] [-s skip_file] [dirs]");
+ bb_error_d("%s\n%s\n", bb_mkdep_terse_options, bb_mkdep_full_options);
}
static const char *kp;
@@ -848,14 +857,14 @@ static void *xmalloc(size_t size)
void *p = malloc(size);
if(p == NULL)
- bb_error_d("memory exhausted");
+ bb_error_d(msg_enomem);
return p;
}
static void *xrealloc(void *p, size_t size) {
p = realloc(p, size);
if(p == NULL)
- bb_error_d("memory exhausted");
+ bb_error_d(msg_enomem);
return p;
}
@@ -890,7 +899,7 @@ static char *bb_xstrdup(const char *s)
char *r = strdup(s);
if(r == NULL)
- bb_error_d("memory exhausted");
+ bb_error_d(msg_enomem);
return r;
}
More information about the busybox
mailing list