From: John Hodge Date: Thu, 24 Oct 2013 04:21:48 +0000 (+0800) Subject: UDI/udibuild - Added trim of leading/trailing spaces to inifile X-Git-Tag: rel0.15~106 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e4a8df96b1b7ba70ae305e78dc8c8829bf55d9f5;p=tpg%2Facess2.git UDI/udibuild - Added trim of leading/trailing spaces to inifile --- diff --git a/UDI/Tools/udibuild_src/inifile.c b/UDI/Tools/udibuild_src/inifile.c index d52a845d..50b0684c 100644 --- a/UDI/Tools/udibuild_src/inifile.c +++ b/UDI/Tools/udibuild_src/inifile.c @@ -1,6 +1,7 @@ /* * udibuild - UDI Compilation Utility * - By John Hodge (thePowersGang) + * Part of the Acess2 OS Project * * inifile.c * - .ini file parsing @@ -77,6 +78,8 @@ tIniFile *IniFile_Load(const char *Path) curSect = new_sect; } else if( sscanf(buf, "%[^=]=%n", name, &ofs) >= 1 ) { + rtrim(name); + while( isspace(buf[ofs]) ) ofs ++; //printf("key %s equals %s\n", name, value); const char *value = buf + ofs; tIniFile_Value *val = malloc(sizeof(tIniFile_Value)+strlen(name)+1+strlen(value)+1); @@ -101,6 +104,9 @@ tIniFile *IniFile_Load(const char *Path) const char *IniFile_Get(tIniFile *File, const char *Sect, const char *Key, const char *Default) { + if( !File ) + return Default; + tIniFile_Section *sect; for( sect = &File->RootSection; sect; sect = sect->Next ) {