Computes the first argument from a list of arguments

@param inString arg,arg,... arg can also be fn(arg,..)
@return the first argument of the given string
516240
static String getNextCommaToken(String inString) {
        String token = "";

        //number of open parenthesis
        int parenthesis = 0;

        for (int i = 0; i < inString.length(); i++) {

            if (OPEN_PARENTHESIS == inString.charAt(i)) {
                parenthesis++;
                token += inString.charAt(i);

            } else if (CLOSE_PARENTHESIS == inString.charAt(i)) {
                parenthesis--;
                token += inString.charAt(i);
            } else if (COMMA == inString.charAt(i)) {
                //if there is no open parenthesis finish
                if (parenthesis == 0) {
                    break;
                } else {
                    token += inString.charAt(i);
                }
            } else {
                token += inString.charAt(i);
            }

        }

        return token;

    }
71079
static void parse(String inString, IContext context, INode parent) {
        List<String> tokens = getCommaTokens(inString);
        for (String token : tokens) {
            int isFunction = token.indexOf(OPEN_PARENTHESIS);
            if (isFunction >= 0) {
                String funcName = token.substring(0, isFunction);
                INode newParent = addChild(parent, context, funcName);
                String arguments = token.substring(isFunction + 1, token.length() - 1);
                parse(arguments, context, newParent);
            } else {
                addChild(parent, context, token);
            }
        }
    }
70781
@Override
	protected List<XExpression> getArguments() {
		List<XExpression> syntacticArguments = getSyntacticArguments();
		XExpression firstArgument = getFirstArgument();
		if (firstArgument != null) {
			return createArgumentList(firstArgument, syntacticArguments);
		}
		return syntacticArguments;
	}
747352
private static void appendArgument(StringBuilder argumentsAsString, int index, String argumentName,
                                       Object[] arguments) {
        argumentsAsString.append(argumentName);
        if (index != arguments.length - 1) {
            argumentsAsString.append(", ");
        }
    }
382516
public static int length(String... args) {
        if (args == null)
            return 0;

        int acc = 0;
        for (String arg : args) {
            acc += arg.length();
        }
        return acc;
    }
1360738
public static Map<String, String> parseArgs(String[] args) {
        Map<String, String> argsMap = new HashMap<>();
        if (null == args || args.length == 0) {
            return argsMap;
        }
        for (String arg : args) {
            if (arg.startsWith("--") && arg.contains("=")) {
                String[] param = arg.substring(2).split("=");
                argsMap.put(param[0], param[1]);
            }
        }
        return argsMap;
    }
943225
public static String or(final String first, final String second) {
    final StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < first.length(); i++) {
      if ('0' == first.charAt(i) && '0' == second.charAt(i)) {
        buffer.append('0');
      } else {
        buffer.append('1');
      }
    }
    return buffer.toString();
  }
815201
public static String arrayAsString(final String[] arg, String separator) {

        StringBuffer result = new StringBuffer();
        for (int i = 0; i < arg.length; i++) {
            result.append(arg[i]);
            if ((i + 1) < arg.length) {
                result.append(separator);
            }
        }
        return result.toString();
    }
235466
public static boolean isNumberStr(String arg) {
        if (StringUtils.isEmpty(arg)) {
            return false;
        }
        return check(arg, NUMBER_STR_PARTER);
    }
1000517
function firstFunction(args) {
  for (var i = 0, len = args.length; i < len; i++) {
    if (typeof args[i] === 'function') {
      return args[i];
    }
  }

  return null;
}
1261
public static int checkArgPositive(final int arg, final String argNameOrErrorMsg) {
        if (arg <= 0) {
            if (argNameOrErrorMsg.indexOf(' ') == N.INDEX_NOT_FOUND) {
                throw new IllegalArgumentException("'" + argNameOrErrorMsg + "' can not be zero or negative: " + arg);
            } else {
                throw new IllegalArgumentException(argNameOrErrorMsg);
            }
        }

        return arg;
    }
852722
public static String[] stripArgs(String[] originalArgs, int stripCount) {
		if (originalArgs.length <= stripCount) {
			return new String[0];
		}
		String[] stripped = new String[originalArgs.length - stripCount];
		for (int i = 0; i < stripped.length; i++) {
			stripped[i] = originalArgs[i+stripCount];
		}
		return stripped;
	}
765939
function checkArgument(i) {
  let l;

  if (l = checkBrackets(i)) tokens[i].argument_child = 1;
  else if (l = checkParentheses(i)) tokens[i].argument_child = 2;
  else if (l = checkSingleValueDeclaration(i)) tokens[i].argument_child = 3;
  else if (l = checkFunctionsList(i)) tokens[i].argument_child = 4;
  else if (l = checkFunction(i)) tokens[i].argument_child = 5;
  else if (l = checkVariablesList(i)) tokens[i].argument_child = 6;
  else if (l = checkVariable(i)) tokens[i].argument_child = 7;
  else if (l = checkSC(i)) tokens[i].argument_child = 8;
  else if (l = checkDelim(i)) tokens[i].argument_child = 9;
  else if (l = checkDeclDelim(i)) tokens[i].argument_child = 10;
  else if (l = checkString(i)) tokens[i].argument_child = 11;
  else if (l = checkPercentage(i)) tokens[i].argument_child = 12;
  else if (l = checkDimension(i)) tokens[i].argument_child = 13;
  else if (l = checkNumber(i)) tokens[i].argument_child = 14;
  else if (l = checkUri(i)) tokens[i].argument_child = 15;
  else if (l = checkInterpolation(i)) tokens[i].argument_child = 16;
  else if (l = checkIdent(i)) tokens[i].argument_child = 17;
  else if (l = checkVhash(i)) tokens[i].argument_child = 18;
  else if (l = checkCustomProperty(i)) tokens[i].argument_child = 19;
  else if (l = checkOperator(i)) tokens[i].argument_child = 20;
  else if (l = checkUnary(i)) tokens[i].argument_child = 21;
  else if (l = checkParentSelector(i)) tokens[i].argument_child = 22;
  else if (l = checkImportant(i)) tokens[i].argument_child = 23;
  else if (l = checkGlobal(i)) tokens[i].argument_child = 24;
  else if (l = checkDefault(i)) tokens[i].argument_child = 25;
  else if (l = checkOptional(i)) tokens[i].argument_child = 26;

  return l;
}
1187681
static public String getString(String msg, int arg)
	{
		return getString(msg, new Object[] { Integer.toString(arg) });
	}
608046
private int init(String[] args) {
    try {
      for (int i = 0; i < args.length; i++) { // parse command line
        if (args[i].equals("-maxDepth")) {
          maxDepth = Integer.parseInt(args[++i]);
          if (maxDepth<1) {
            System.err.println("maxDepth must be positive: " + maxDepth);
            return -1;
          }
        } else if (args[i].equals("-minWidth")) {
          minWidth = Integer.parseInt(args[++i]);
          if (minWidth<0) {
            System.err.println("minWidth must be positive: " + minWidth);
            return -1;
          }
        } else if (args[i].equals("-maxWidth")) {
          maxWidth = Integer.parseInt(args[++i]);
        } else if (args[i].equals("-numOfFiles")) {
          numOfFiles = Integer.parseInt(args[++i]);
          if (numOfFiles<1) {
            System.err.println("NumOfFiles must be positive: " + numOfFiles);
            return -1;
          }
        } else if (args[i].equals("-avgFileSize")) {
          avgFileSize = Double.parseDouble(args[++i]);
          if (avgFileSize<=0) {
            System.err.println("AvgFileSize must be positive: " + avgFileSize);
            return -1;
          }
        } else if (args[i].equals("-outDir")) {
          outDir = new File(args[++i]);
        } else if (args[i].equals("-seed")) {
          r = new Random(Long.parseLong(args[++i]));
        } else {
          System.err.println(USAGE);
          ToolRunner.printGenericCommandUsage(System.err);
          return -1;
        }
      }
    } catch (NumberFormatException e) {
      System.err.println("Illegal parameter: " + e.getLocalizedMessage());
      System.err.println(USAGE);
      return -1;
    }

    if (maxWidth < minWidth) {
      System.err.println(
          "maxWidth must be bigger than minWidth: " + maxWidth);
      return -1;
    }

    if (r==null) {
      r = new Random();
    }
    return 0;
  }
1228738
public static String format(String formatString, Object... args) {
    // Rewrites the varargs so that objects that need special formatting are
    // replaced with formatted strings, then hands off to {@link String#format}.

    Object[] formattedArgs = new Object[args.length];
    for (int i = 0; i < args.length; ++i) {
      formattedArgs[i] = formatObject(args[i]);
    }

    return String.format(formatString, (Object[]) formattedArgs);
  }
157984
private static String[] harvestApplicationWithArguments(String arg)
    {
        List<String> args = new ArrayList<>();

        if (arg.trim().length() >= 0)
        {
            String appl = "", data = "";

            /* Find the first occurrence of either '(' or ',' */
            int firstc = arg.indexOf(',');
            int firstp = arg.indexOf('(');

            if (firstc != -1 && (firstp == -1 || firstc < firstp))
            {
                /* comma found, no parenthesis */
                /* or both found, but comma found first */
                String[] split = arg.split(",");
                appl = split[0];
                for (int i = 1; i < split.length; i++)
                    data += split[i] + (i + 1 < split.length ? "," : "");
            }
            else if (firstc == -1 && firstp == -1)
            {
                /* Neither found */
                data = "";
            }
            else
            {
                /* Final remaining case is parenthesis found first */
                String[] split = arg.split("\\(");
                appl = split[0];
                for (int i = 1; i < split.length; i++)
                    data += split[i] + (i + 1 < split.length ? "(" : "");
                int end = data.lastIndexOf(')');
                if (end == -1)
                {
                    // ast_log(LOG_WARNING, "No closing parenthesis found?
                    // '%s(%s'\n", appl, data);
                }
                else if (end == data.length() - 1)
                {
                    data = data.substring(0, end);
                }
                data = processQuotesAndSlashes(data, ',', '|');
            }

            if (!appl.trim().equals(""))
            {
                args.add(appl.trim());
                if (!data.trim().equals(""))
                {
                    String[] dataSplit = data.split("\\|");
                    for (String aDataSplit : dataSplit)
                    {
                        args.add(aDataSplit.trim());
                    }
                }
            }
        }

        return args.toArray(new String[args.size()]);
    }