Пример #1
0
 static inline UnicodeString fixdesc(const UnicodeString& desc) {
     if (desc.endsWith(LTLT, 2)) {
         UnicodeString result(desc, 0, desc.length()-1);
         return result;
     }
     return desc;
 }
Пример #2
0
int pelet::SkipToIdentifier(BufferClass *buffer, UnicodeString identifier) {
	bool end = false;
	
	// add semicolon to make checks easier
	identifier.append(';');
	UChar c = *buffer->Current;
	while (!end) {
	
		/*
		 * read one line at a time.  If the line is the identifier we'll stop. If we reach the
		 * end, then this heredoc in unterminated.
		 * be careful; do NOT store buffer->Current since it may change at any after buffer->AppendToLexeme
		 * is called
		 */
		UnicodeString line;
		while (c != 0 && c != '\n' && c != '\r') {
			line.append(c);
			
			// only fill buffer when we its close to being filled up; this will prevent
			// useless copying of the buffer to remove slack
			if ((buffer->Limit - buffer->Current) < 2) {
				buffer->AppendToLexeme(1);
			}
			c = *(++buffer->Current);
			
		}
		if (c == 0) {
			end = true;
			return T_ERROR_UNTERMINATED_STRING;
		}
		
		// since we are eating up a  newline, otherwise line numbering in lint errors
		// will be wrong
		buffer->IncrementLine();
		bool hasEndingSemicolon = true;
		if (!line.endsWith(UNICODE_STRING(";", 1))) {
			line.append(UNICODE_STRING(";", 1));
			hasEndingSemicolon = false;
		}
		if (line.compare(identifier) == 0) {
			end = true;
			
			// semicolons and newlines are NOT part of the nowdoc; the parser will look for semicolons
			// semicolon is OPTIONAL for heredoc / nowdoc
			if (hasEndingSemicolon) {
				buffer->Current--;
			}
		}
		else {
			if ((buffer->Limit - buffer->Current) < 2) {
				buffer->AppendToLexeme(1);
			}
			c = *(++buffer->Current);
		}
	}
	return 0;
}
Пример #3
0
 NumeratorSubstitution(int32_t _pos,
     double _denominator,
     const NFRuleSet* _ruleSet,
     const RuleBasedNumberFormat* formatter,
     const UnicodeString& description,
     UErrorCode& status)
     : NFSubstitution(_pos, _ruleSet, formatter, fixdesc(description), status), denominator(_denominator) 
 {
     ldenominator = util64_fromDouble(denominator);
     withZeros = description.endsWith(LTLT, 2);
 }
Пример #4
0
void MessageFormatRegressionTest::Test4142938() 
{
    UnicodeString pat = CharsToUnicodeString("''Vous'' {0,choice,0#n''|1#}avez s\\u00E9lectionn\\u00E9 "
        "{0,choice,0#aucun|1#{0}} client{0,choice,0#s|1#|2#s} "
        "personnel{0,choice,0#s|1#|2#s}.");
    UErrorCode status = U_ZERO_ERROR;
    MessageFormat *mf = new MessageFormat(pat, status);
    failure(status, "new MessageFormat");

    UnicodeString PREFIX [] = {
        CharsToUnicodeString("'Vous' n'avez s\\u00E9lectionn\\u00E9 aucun clients personnels."),
        CharsToUnicodeString("'Vous' avez s\\u00E9lectionn\\u00E9 "),
        CharsToUnicodeString("'Vous' avez s\\u00E9lectionn\\u00E9 ")
    };  
    UnicodeString SUFFIX [] = {
        UnicodeString(),
        UNICODE_STRING(" client personnel.", 18),
        UNICODE_STRING(" clients personnels.", 20)
    };

    for (int i=0; i<3; i++) {
        UnicodeString out;
        //out = mf->format(new Object[]{new Integer(i)});
        Formattable objs [] = {
            Formattable((int32_t)i)
        };
        FieldPosition pos(FieldPosition::DONT_CARE);
        out = mf->format(objs, 1, out, pos, status);
        if (!failure(status, "mf->format", TRUE)) {
            if (SUFFIX[i] == "") {
                if (out != PREFIX[i])
                    errln((UnicodeString)"" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
            }
            else {
                if (!out.startsWith(PREFIX[i]) ||
                    !out.endsWith(SUFFIX[i]))
                    errln((UnicodeString)"" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"...\"" +
                          SUFFIX[i] + "\"");
            }
        }
    }

    delete mf;
}