mojoshader_preprocessor.c
changeset 952 7e7d5737f9a6
parent 951 6ef73d06ecb0
child 953 ebcde4f1e376
equal deleted inserted replaced
951:6ef73d06ecb0 952:7e7d5737f9a6
  1429         if (buffer_size(buffer) == 0)
  1429         if (buffer_size(buffer) == 0)
  1430             void_call = ((saw_params == 0) && (paren == 0));
  1430             void_call = ((saw_params == 0) && (paren == 0));
  1431 
  1431 
  1432         if (saw_params < expected)
  1432         if (saw_params < expected)
  1433         {
  1433         {
       
  1434             const int origdeflen = (int) buffer_size(origbuffer);
  1434             char *origdefinition = buffer_flatten(origbuffer);
  1435             char *origdefinition = buffer_flatten(origbuffer);
       
  1436             const int deflen = (int) buffer_size(buffer);
  1435             char *definition = buffer_flatten(buffer);
  1437             char *definition = buffer_flatten(buffer);
  1436             Define *p = get_define(ctx);
  1438             Define *p = get_define(ctx);
  1437             if ((!origdefinition) || (!definition) || (!p))
  1439             if ((!origdefinition) || (!definition) || (!p))
  1438             {
  1440             {
  1439                 Free(ctx, origdefinition);
  1441                 Free(ctx, origdefinition);
  1444                 goto handle_macro_args_failed;
  1446                 goto handle_macro_args_failed;
  1445             } // if
  1447             } // if
  1446 
  1448 
  1447             // trim any whitespace from the end of the string...
  1449             // trim any whitespace from the end of the string...
  1448             int i;
  1450             int i;
  1449             for (i = (int) buffer_size(buffer) - 1; i >= 0; i--)
  1451             for (i = deflen - 1; i >= 0; i--)
  1450             {
  1452             {
  1451                 if (definition[i] == ' ')
  1453                 if (definition[i] == ' ')
  1452                     definition[i] = '\0';
  1454                     definition[i] = '\0';
  1453                 else
  1455                 else
  1454                     break;
  1456                     break;
  1455             } // for
  1457             } // for
  1456 
  1458 
  1457             for (i = (int) buffer_size(origbuffer) - 1; i >= 0; i--)
  1459             for (i = origdeflen - 1; i >= 0; i--)
  1458             {
  1460             {
  1459                 if (origdefinition[i] == ' ')
  1461                 if (origdefinition[i] == ' ')
  1460                     origdefinition[i] = '\0';
  1462                     origdefinition[i] = '\0';
  1461                 else
  1463                 else
  1462                     break;
  1464                     break;