Changeset 845 for cpp


Ignore:
Timestamp:
01/06/19 02:41:09 (5 years ago)
Author:
Maciej Komosinski
Message:

Made strings at least slightly comparable with zero so 'Math.pi && "xyz" && [9,9,7]' can work as expected in FramScript?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/extvalue.cpp

    r794 r845  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    435435                else if (src.getType() == TDouble)
    436436                        return compareFloat((double)idata(), src.getDouble());
     437                else if ((getInt() == 0) && (src.getType() == TString))
     438                        return ResultMismatch_RelaxedUnequal;
    437439                else
    438440                        return ResultMismatch;//comparing numbers with other things is invalid
     
    449451                if (src.getType() == TString)
    450452                        return compareString(sdata(), src.getString());
     453                else if ((src.type == TInt) && (src.getInt() == 0))
     454                        return ResultMismatch_RelaxedUnequal;
    451455                else
    452456                        return ResultMismatch;
     
    491495                        if (context->v1 && context->v2)
    492496                                msg += SString::sprintf(": %s %s %s",
    493                                 context->v1->typeAndValue().c_str(),
    494                                 cmp_op_names[op - CmpFIRST],
    495                                 context->v2->typeAndValue().c_str());
     497                                        context->v1->typeAndValue().c_str(),
     498                                        cmp_op_names[op - CmpFIRST],
     499                                        context->v2->typeAndValue().c_str());
    496500                }
    497501                logPrintf("ExtValue", "interpretCompare", LOG_ERROR, "%s", msg.c_str());
     
    559563                }
    560564        }
    561                 //NO break;
     565        //NO break;
    562566        default:;
    563567        }
     
    661665                }
    662666        }
    663                 //NO break;
     667        //NO break;
    664668        default:;
    665669        }
     
    813817                        for (const char* t = curr; t < next; t++)
    814818                                switch (*t)
    815                         {
     819                                {
    816820                                case 'd': case 'x': case 'X': case 'u': case 'p': case 'c': type = 'd'; t = next; break;
    817821                                case 'f': case 'g': case 'e': type = 'f'; t = next; break;
     
    819823                                case 't': case 'T': case 'y': case 'i': case 'm': type = *t; t = next; break;
    820824                                case '%': if (t > begin) { type = *t; t = next; } break;
    821                         }
     825                                }
    822826                }
    823827                if (curr > begin) curr--;
     
    887891                }
    888892        }
    889                 break;
     893        break;
    890894
    891895        case TObj: case TUnknown: case TInvalid:
     
    12391243                        if (*end == '>')
    12401244                        {
    1241                         setError(SString("Unserializable class: ") + SString(in + 1, end - in - 1));
    1242                         return end + 1;
     1245                                setError(SString("Unserializable class: ") + SString(in + 1, end - in - 1));
     1246                                return end + 1;
    12431247                        }
    12441248                        else
Note: See TracChangeset for help on using the changeset viewer.