diff options
author | unknown <monty@mysql.com> | 2005-04-26 23:24:59 +0300 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-04-26 23:24:59 +0300 |
commit | bf17c826deb66a82fe528e4a95edb4caee0ff652 (patch) | |
tree | d3f9869f90a3254e9a596cab6776bef2d44dfdc4 /mysys | |
parent | d8871a117b805ba91cb4d305db542e0ec91ec9f4 (diff) | |
download | mariadb-git-bf17c826deb66a82fe528e4a95edb4caee0ff652.tar.gz |
Cleanups during review
mysys/default.c:
Cleanup:
- Just test once for recursion level
- Don't test explicitely for \r or \n as my_isspace() already does that
sql/sql_insert.cc:
Fix argument
sql/sql_select.cc:
Fixed indentation
added comment
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/default.c | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/mysys/default.c b/mysys/default.c index 63323f15fd5..4ee2041bc39 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -402,33 +402,48 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, continue; /* Configuration File Directives */ - if ((*ptr == '!') && (recursion_level < max_recursion_level)) + if ((*ptr == '!')) { + if (recursion_level >= max_recursion_level) + { + for (end= ptr + strlen(ptr) - 1; + my_isspace(&my_charset_latin1, *(end - 1)); + end--) + {} + end[0]= 0; + fprintf(stderr, + "Warning: skipping '%s' directive as maximum include" + "recursion level was reached in file %s at line %d\n", + ptr, name, line); + continue; + } + /* skip over `!' and following whitespace */ for (++ptr; my_isspace(&my_charset_latin1, ptr[0]); ptr++) {} - if ((!strncmp(ptr, includedir_keyword, sizeof(includedir_keyword) - 1)) - && my_isspace(&my_charset_latin1, ptr[sizeof(includedir_keyword) - 1])) + if ((!strncmp(ptr, includedir_keyword, + sizeof(includedir_keyword) - 1)) && + my_isspace(&my_charset_latin1, ptr[sizeof(includedir_keyword) - 1])) { /* skip over "includedir" and following whitespace */ for (ptr+= sizeof(includedir_keyword) - 1; my_isspace(&my_charset_latin1, ptr[0]); ptr++) {} - /* trim trailing whitespace from directory name */ - end= ptr + strlen(ptr) - 1; - /* fgets() stores the newline character in the buffer */ - if ((end[0] == '\n') || (end[0] == '\r') || - my_isspace(&my_charset_latin1, end[0])) - { - for (; my_isspace(&my_charset_latin1, *(end - 1)); end--) - {} - end[0]= 0; - } + /* + trim trailing whitespace from directory name + The -1 below is for the newline added by fgets() + Note that my_isspace() is true for \r and \n + */ + for (end= ptr + strlen(ptr) - 1; + my_isspace(&my_charset_latin1, *(end - 1)); + end--) + {} + end[0]= 0; /* print error msg if there is nothing after !includedir directive */ - if (end == ptr) + if (end <= ptr) { fprintf(stderr, "error: Wrong !includedir directive in config " @@ -468,8 +483,8 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, my_dirend(search_dir); } - else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1)) - && my_isspace(&my_charset_latin1, ptr[sizeof(include_keyword) - 1])) + else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1)) && + my_isspace(&my_charset_latin1, ptr[sizeof(include_keyword)-1])) { /* skip over `include' and following whitespace */ for (ptr+= sizeof(include_keyword) - 1; @@ -477,12 +492,13 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, {} /* trim trailing whitespace from filename */ - end= ptr + strlen(ptr) - 1; - for (; my_isspace(&my_charset_latin1, *(end - 1)) ; end--) + for (end= ptr + strlen(ptr) - 1; + my_isspace(&my_charset_latin1, *(end - 1)); + end--) {} end[0]= 0; - if (end == ptr) + if (end <= ptr) { fprintf(stderr, "error: Wrong !include directive in config " @@ -497,14 +513,6 @@ static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, continue; } - else - if (recursion_level >= max_recursion_level) - { - fprintf(stderr, - "warning: skipping !include directive as maximum include" - "recursion level was reached in file %s at line %d\n", - name, line); - } if (*ptr == '[') /* Group name */ { |