Skip to content

Commit

Permalink
Merge pull request ndevilla#93 from Tropicao/master
Browse files Browse the repository at this point in the history
Add basic iniparser.pc
  • Loading branch information
ndevilla authored and hityc2019 committed Jun 11, 2019
2 parents 0a38e85 + a6b376f commit abd54d8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
12 changes: 12 additions & 0 deletions iniparser.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=/usr
exec_prefix=/usr
libdir=${exec_prefix}/lib
includedir=${prefix}/include
datarootdir=${prefix}/share
datadir=${datarootdir}

Name: libiniparser
Description: Iniparser library
Version: 4.1
Libs: -L${libdir} -liniparser
Cflags: -I${includedir}
36 changes: 33 additions & 3 deletions src/iniparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ dictionary * iniparser_load(const char * ininame)
int errs=0;
int mem_err=0;

int connect_pos=0;
int detect_len;

dictionary * dict ;

if ((in=fopen(ininame, "r"))==NULL) {
Expand All @@ -747,6 +750,10 @@ dictionary * iniparser_load(const char * ininame)
last=0 ;

while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) {
char equal_flag=0;
char comment_flag=0;
char connect_flag=0;

lineno++ ;
len = (int)strlen(line)-1;
if (len<=0)
Expand All @@ -764,8 +771,26 @@ dictionary * iniparser_load(const char * ininame)
/* Get rid of \n and spaces at end of line */
while ((len>=0) &&
((line[len]=='\n') || (isspace(line[len])))) {
line[len]=0 ;
len-- ;
line[len]=0;
len--;
}
/* detect string include these "=", "\", ";" or "#" */
detect_len = len;
while (line[len]!='\\' && detect_len>=0){
if (line[detect_len]==';' || line[detect_len]=='#'){
comment_flag=1;

}
if (comment_flag==1 && connect_flag ==0 && line[detect_len]=='\\'){
connect_flag=1;
connect_pos=detect_len ;
}
if (connect_flag==1 && line[detect_len]=='='){
equal_flag=1 ;
break;

}
detect_len--;
}
if (len < 0) { /* Line was entirely \n and/or spaces */
len = 0;
Expand All @@ -775,9 +800,14 @@ dictionary * iniparser_load(const char * ininame)
/* Multi-line value */
last=len ;
continue ;
} else {
}
else if (equal_flag & connect_flag & comment_flag){
last = connect_pos ;
continue ;
}else {
last=0 ;
}

switch (iniparser_line(line, section, key, val)) {
case LINE_EMPTY:
case LINE_COMMENT:
Expand Down

0 comments on commit abd54d8

Please sign in to comment.