Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 136 | Rev 161 | ||
---|---|---|---|
Line 859... | Line 859... | ||
859 | current_section[i - fieldstart] = 0; // and terminate the string |
859 | current_section[i - fieldstart] = 0; // and terminate the string |
860 | 860 | ||
861 | INIFile_WriteEntryAsString (dictionary, current_section, NULL, NULL); // add to dictionary |
861 | INIFile_WriteEntryAsString (dictionary, current_section, NULL, NULL); // add to dictionary |
862 | } |
862 | } |
863 | 863 | ||
- | 864 | // else is it a valid entry/value pair whose entry is enclosed between quotes? |
|
- | 865 | else if ((swscanf_s (line_buffer, L"\"%[^\"]\" = %[^;#]", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
|
- | 866 | || (swscanf_s (line_buffer, L"'%[^']' = %[^;#]", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2)) |
|
- | 867 | { |
|
- | 868 | // when entry is enclosed between quotes, DO NOT strip the blanks |
|
- | 869 | ||
- | 870 | length = (int) wcslen (current_value); // get the value string length |
|
- | 871 | ||
- | 872 | fieldstart = 0; // let's now strip leading blanks |
|
- | 873 | while ((fieldstart < length) && iswspace (current_value[fieldstart])) |
|
- | 874 | fieldstart++; // ignore any tabs or spaces, going forward from the start |
|
- | 875 | ||
- | 876 | fieldstop = length - 1; // let's now strip trailing blanks |
|
- | 877 | while ((fieldstop >= 0) && iswspace (current_value[fieldstop])) |
|
- | 878 | fieldstop--; // ignore any tabs or spaces, going backwards from the end |
|
- | 879 | ||
- | 880 | for (i = fieldstart; i <= fieldstop; i++) |
|
- | 881 | current_value[i - fieldstart] = current_value[i]; // recopy entry name w/out spaces |
|
- | 882 | current_value[i - fieldstart] = 0; // and terminate the string |
|
- | 883 | ||
- | 884 | // sscanf cannot handle "" or '' as empty value, this is done here |
|
- | 885 | if ((wcscmp (current_value, L"\"\"") == 0) || (wcscmp (current_value, L"''") == 0)) |
|
- | 886 | current_value[0] = 0; // empty string |
|
- | 887 | ||
- | 888 | INIFile_WriteEntryAsString (dictionary, current_section, current_entry, current_value); // add to dictionary |
|
- | 889 | } |
|
- | 890 | ||
- | 891 | // else is it a valid entry/value pair whose entry AND value are enclosed between quotes? |
|
- | 892 | else if ((swscanf_s (line_buffer, L"\"%[^\"]\" = \"%[^\"]\"", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
|
- | 893 | || (swscanf_s (line_buffer, L"'%[^']' = \"%[^\"]\"", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
|
- | 894 | || (swscanf_s (line_buffer, L"\"%[^\"]\" = '%[^']'", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
|
- | 895 | || (swscanf_s (line_buffer, L"'%[^']' = '%[^']'", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2)) |
|
- | 896 | { |
|
- | 897 | // when entry is enclosed between quotes, DO NOT strip the blanks |
|
- | 898 | ||
- | 899 | // when value is enclosed between quotes, DO NOT strip the blanks |
|
- | 900 | ||
- | 901 | // sscanf cannot handle "" or '' as empty value, this is done here |
|
- | 902 | if ((wcscmp (current_value, L"\"\"") == 0) || (wcscmp (current_value, L"''") == 0)) |
|
- | 903 | current_value[0] = 0; // empty string |
|
- | 904 | ||
- | 905 | INIFile_WriteEntryAsString (dictionary, current_section, current_entry, current_value); // add to dictionary |
|
- | 906 | } |
|
- | 907 | ||
864 | // else is it a valid entry/value pair |
908 | // else is it a valid entry/value pair whose value is enclosed between quotes? |
865 | else if (swscanf_s (line_buffer, L"%[^=] = \"%[^\"]\"", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
909 | else if ((swscanf_s (line_buffer, L"%[^=] = \"%[^\"]\"", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
- | 910 | || (swscanf_s (line_buffer, L"%[^=] = '%[^']'", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2)) |
|
866 | { |
911 | { |
867 | length = (int) wcslen (current_entry); // get the entry string length |
912 | length = (int) wcslen (current_entry); // get the entry string length |
868 | 913 | ||
869 | fieldstart = 0; // let's now strip leading blanks |
914 | fieldstart = 0; // let's now strip leading blanks |
870 | while ((fieldstart < length) && iswspace (current_entry[fieldstart])) |
915 | while ((fieldstart < length) && iswspace (current_entry[fieldstart])) |
Line 886... | Line 931... | ||
886 | 931 | ||
887 | INIFile_WriteEntryAsString (dictionary, current_section, current_entry, current_value); // add to dictionary |
932 | INIFile_WriteEntryAsString (dictionary, current_section, current_entry, current_value); // add to dictionary |
888 | } |
933 | } |
889 | 934 | ||
890 | // else is it a valid entry/value pair without quotes ? |
935 | // else is it a valid entry/value pair without quotes ? |
891 | else if |
936 | else if (swscanf_s (line_buffer, L"%[^=] = %[^;#]", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2) |
892 | || (swscanf_s (line_buffer, L"%[^=] = %[^;#]", current_entry, STRING_MAXSIZE, current_value, STRING_MAXSIZE) == 2)) |
- | |
893 | { |
937 | { |
894 | length = (int) wcslen (current_entry); // get the entry string length |
938 | length = (int) wcslen (current_entry); // get the entry string length |
895 | 939 | ||
896 | fieldstart = 0; // let's now strip leading blanks |
940 | fieldstart = 0; // let's now strip leading blanks |
897 | while ((fieldstart < length) && iswspace (current_entry[fieldstart])) |
941 | while ((fieldstart < length) && iswspace (current_entry[fieldstart])) |