Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=0520c9c69a18f3ea60fa2256a6f038fbf4b6c864
commit 0520c9c69a18f3ea60fa2256a6f038fbf4b6c864 Author: James Buren <[email protected]> Date: Sun Mar 3 02:40:09 2013 -0600 strip newline when using strtok or strsep to parse input diff --git a/new/fwsetup/layout.c b/new/fwsetup/layout.c index a4df6cd..70f62ad 100644 --- a/new/fwsetup/layout.c +++ b/new/fwsetup/layout.c @@ -31,7 +31,7 @@ static char **entries = 0; static inline bool get_token(char *in,char **out) { - return (*out = strtok(in," \t")) != 0; + return (*out = strtok(in,SPACE_CHARS)) != 0; } static inline void put_token(char *in,char **out) diff --git a/new/fwsetup/local.h b/new/fwsetup/local.h index 299a803..e244986 100644 --- a/new/fwsetup/local.h +++ b/new/fwsetup/local.h @@ -47,6 +47,7 @@ #define LOGFILE "/var/log/fwsetup.log" #define INSTALL_ROOT "/mnt/install" +#define SPACE_CHARS " \t\r\n\v\f" #define TEXT_MAX 8192 #define KIBIBYTE (1LL << 10LL) #define MEBIBYTE (1LL << 20LL) diff --git a/new/fwsetup/locale.c b/new/fwsetup/locale.c index f0467e1..d816e5a 100644 --- a/new/fwsetup/locale.c +++ b/new/fwsetup/locale.c @@ -26,6 +26,7 @@ static bool locale_setup(void) size_t i = 0; size_t size = 4096; char line[LINE_MAX] = {0}; + char *locale = 0; strfcpy(command,sizeof(command),"locale --all-locales | grep '\\.utf8$' | sort --unique"); @@ -40,12 +41,12 @@ static bool locale_setup(void) while(fgets(line,sizeof(line),pipe) != 0) { if( - i == size - 1 || - strlen(line) == 0 + i == size - 1 || + (locale = strtok(line,SPACE_CHARS)) == 0 ) continue; - locales[i++] = strdup(line); + locales[i++] = strdup(locale); } locales[i] = 0; diff --git a/new/fwsetup/postconfig.c b/new/fwsetup/postconfig.c index c2388ee..b9fcacf 100644 --- a/new/fwsetup/postconfig.c +++ b/new/fwsetup/postconfig.c @@ -262,9 +262,9 @@ static bool write_fstab(void) for( p = g->fstabdata ; *p != 0 ; ++p ) { if( - (device = strtok(*p,":")) == 0 || - (path = strtok(0,":")) == 0 || - (filesystem = strtok(0,":")) == 0 || + (device = strtok(*p,":\n")) == 0 || + (path = strtok(0,":\n")) == 0 || + (filesystem = strtok(0,":\n")) == 0 || (uuid = probe_uuid(device)) == 0 ) { @@ -331,10 +331,10 @@ static bool is_root_setup(void) { tmp = line; - if((user = strsep(&tmp,":")) == 0) + if((user = strsep(&tmp,":\n")) == 0) continue; - if((pwd = strsep(&tmp,":")) == 0) + if((pwd = strsep(&tmp,":\n")) == 0) continue; if(strcmp(user,"root") == 0) @@ -369,16 +369,16 @@ static bool is_user_setup(void) { tmp = line; - if(strsep(&tmp,":") == 0) + if(strsep(&tmp,":\n") == 0) continue; - if(strsep(&tmp,":") == 0) + if(strsep(&tmp,":\n") == 0) continue; - if(strsep(&tmp,":") == 0) + if(strsep(&tmp,":\n") == 0) continue; - if((gid = strsep(&tmp,":")) == 0) + if((gid = strsep(&tmp,":\n")) == 0) continue; if(strcmp(gid,"100") == 0) _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
