/* * Extract the setting after the '=' and store it in flag excluding the newline character. */ static void extractFlag(char* buffer, int32_t bufferSize, char* flag, int32_t flagSize, UErrorCode *status) { int32_t i; char *pBuffer; int32_t offset; UBool bufferWritten = FALSE; if (buffer[0] != 0) { /* Get the offset (i.e. position after the '=') */ offset = getFlagOffset(buffer, bufferSize); pBuffer = buffer+offset; for(i = 0;;i++) { if (i >= flagSize) { *status = U_BUFFER_OVERFLOW_ERROR; return; } if (pBuffer[i+1] == 0) { /* Indicates a new line character. End here. */ flag[i] = 0; break; } flag[i] = pBuffer[i]; if (i == 0) { bufferWritten = TRUE; } } } if (!bufferWritten) { flag[0] = 0; } }
/* * Extract the setting after the '=' and store it in flag excluding the newline character. */ static int32_t extractFlag(char* buffer, int32_t bufferSize, char* flag, int32_t flagSize, const char **flagNames, int32_t numOfFlags, UErrorCode *status) { int32_t i, idx = -1; char *pBuffer; int32_t offset=0; UBool bufferWritten = FALSE; if (buffer[0] != 0) { /* Get the offset (i.e. position after the '=') */ offset = getFlagOffset(buffer, bufferSize); pBuffer = buffer+offset; for(i = 0;;i++) { if (i >= flagSize) { *status = U_BUFFER_OVERFLOW_ERROR; return -1; } if (pBuffer[i+1] == 0) { /* Indicates a new line character. End here. */ flag[i] = 0; break; } flag[i] = pBuffer[i]; if (i == 0) { bufferWritten = TRUE; } } } if (!bufferWritten) { flag[0] = 0; } if (flagNames != NULL && offset>0) { offset--; /* Move offset back 1 because of '='*/ for (i = 0; i < numOfFlags; i++) { if (uprv_strncmp(buffer, flagNames[i], offset) == 0) { idx = i; break; } } } return idx; }