aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 01:30:49 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 01:30:49 +0200
commita493441ca52adca7df3976c668f2e7c48d1b67a1 (patch)
treed62c6b5143e826ff046a4f1130ef3da59e6a5ba2
parentadcd9a6f349f3f2715a586b45fb27350b37cf1e5 (diff)
downloadbusybox-w32-a493441ca52adca7df3976c668f2e7c48d1b67a1.tar.gz
busybox-w32-a493441ca52adca7df3976c668f2e7c48d1b67a1.tar.bz2
busybox-w32-a493441ca52adca7df3976c668f2e7c48d1b67a1.zip
awk: deindent code block, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c177
1 files changed, 90 insertions, 87 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 764a3dd49..9a3b63df6 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1337,8 +1337,9 @@ static node *parse_expr(uint32_t term_tc)
1337 cn->a.n = glptr; 1337 cn->a.n = glptr;
1338 expected_tc = TS_OPERAND | TS_UOPPRE; 1338 expected_tc = TS_OPERAND | TS_UOPPRE;
1339 glptr = NULL; 1339 glptr = NULL;
1340 1340 continue;
1341 } else if (tc & (TS_BINOP | TC_UOPPOST)) { 1341 }
1342 if (tc & (TS_BINOP | TC_UOPPOST)) {
1342 debug_printf_parse("%s: TS_BINOP | TC_UOPPOST tc:%x\n", __func__, tc); 1343 debug_printf_parse("%s: TS_BINOP | TC_UOPPOST tc:%x\n", __func__, tc);
1343 /* for binary and postfix-unary operators, jump back over 1344 /* for binary and postfix-unary operators, jump back over
1344 * previous operators with higher priority */ 1345 * previous operators with higher priority */
@@ -1368,101 +1369,103 @@ static node *parse_expr(uint32_t term_tc)
1368 expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc; 1369 expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
1369 } 1370 }
1370 vn->a.n = cn; 1371 vn->a.n = cn;
1372 continue;
1373 }
1371 1374
1372 } else { 1375 debug_printf_parse("%s: other, t_info:%x\n", __func__, t_info);
1373 debug_printf_parse("%s: other, t_info:%x\n", __func__, t_info); 1376 /* for operands and prefix-unary operators, attach them
1374 /* for operands and prefix-unary operators, attach them 1377 * to last node */
1375 * to last node */ 1378 vn = cn;
1376 vn = cn; 1379 cn = vn->r.n = new_node(t_info);
1377 cn = vn->r.n = new_node(t_info); 1380 cn->a.n = vn;
1378 cn->a.n = vn;
1379 1381
1380 expected_tc = TS_OPERAND | TS_UOPPRE | TC_REGEXP; 1382 expected_tc = TS_OPERAND | TS_UOPPRE | TC_REGEXP;
1381 if (t_info == TI_PREINC || t_info == TI_PREDEC) 1383 if (t_info == TI_PREINC || t_info == TI_PREDEC)
1382 expected_tc = TS_LVALUE | TC_UOPPRE1; 1384 expected_tc = TS_LVALUE | TC_UOPPRE1;
1383 if (tc & (TS_OPERAND | TC_REGEXP)) {
1384 debug_printf_parse("%s: TS_OPERAND | TC_REGEXP\n", __func__);
1385 expected_tc = TS_UOPPRE | TC_UOPPOST | TS_BINOP | TS_OPERAND | term_tc;
1386 /* one should be very careful with switch on tclass -
1387 * only simple tclasses should be used (TC_xyz, not TS_xyz) */
1388 switch (tc) {
1389 case TC_VARIABLE:
1390 case TC_ARRAY:
1391 debug_printf_parse("%s: TC_VARIABLE | TC_ARRAY\n", __func__);
1392 cn->info = OC_VAR;
1393 v = hash_search(ahash, t_string);
1394 if (v != NULL) {
1395 cn->info = OC_FNARG;
1396 cn->l.aidx = v->x.aidx;
1397 } else {
1398 cn->l.v = newvar(t_string);
1399 }
1400 if (tc & TC_ARRAY) {
1401 cn->info |= xS;
1402 cn->r.n = parse_expr(TC_ARRTERM);
1403 }
1404 break;
1405 1385
1406 case TC_NUMBER: 1386 if (!(tc & (TS_OPERAND | TC_REGEXP)))
1407 case TC_STRING: 1387 continue;
1408 debug_printf_parse("%s: TC_NUMBER | TC_STRING\n", __func__);
1409 cn->info = OC_VAR;
1410 v = cn->l.v = xzalloc(sizeof(var));
1411 if (tc & TC_NUMBER)
1412 setvar_i(v, t_double);
1413 else {
1414 setvar_s(v, t_string);
1415 expected_tc &= ~TC_UOPPOST; /* "str"++ is not allowed */
1416 }
1417 break;
1418 1388
1419 case TC_REGEXP: 1389 debug_printf_parse("%s: TS_OPERAND | TC_REGEXP\n", __func__);
1420 debug_printf_parse("%s: TC_REGEXP\n", __func__); 1390 expected_tc = TS_UOPPRE | TC_UOPPOST | TS_BINOP | TS_OPERAND | term_tc;
1421 mk_re_node(t_string, cn, xzalloc(sizeof(regex_t)*2)); 1391 /* one should be very careful with switch on tclass -
1422 break; 1392 * only simple tclasses should be used (TC_xyz, not TS_xyz) */
1393 switch (tc) {
1394 case TC_VARIABLE:
1395 case TC_ARRAY:
1396 debug_printf_parse("%s: TC_VARIABLE | TC_ARRAY\n", __func__);
1397 cn->info = OC_VAR;
1398 v = hash_search(ahash, t_string);
1399 if (v != NULL) {
1400 cn->info = OC_FNARG;
1401 cn->l.aidx = v->x.aidx;
1402 } else {
1403 cn->l.v = newvar(t_string);
1404 }
1405 if (tc & TC_ARRAY) {
1406 cn->info |= xS;
1407 cn->r.n = parse_expr(TC_ARRTERM);
1408 }
1409 break;
1423 1410
1424 case TC_FUNCTION: 1411 case TC_NUMBER:
1425 debug_printf_parse("%s: TC_FUNCTION\n", __func__); 1412 case TC_STRING:
1426 cn->info = OC_FUNC; 1413 debug_printf_parse("%s: TC_NUMBER | TC_STRING\n", __func__);
1427 cn->r.f = newfunc(t_string); 1414 cn->info = OC_VAR;
1428 cn->l.n = condition(); 1415 v = cn->l.v = xzalloc(sizeof(var));
1429 break; 1416 if (tc & TC_NUMBER)
1417 setvar_i(v, t_double);
1418 else {
1419 setvar_s(v, t_string);
1420 expected_tc &= ~TC_UOPPOST; /* "str"++ is not allowed */
1421 }
1422 break;
1430 1423
1431 case TC_SEQSTART: 1424 case TC_REGEXP:
1432 debug_printf_parse("%s: TC_SEQSTART\n", __func__); 1425 debug_printf_parse("%s: TC_REGEXP\n", __func__);
1433 cn = vn->r.n = parse_expr(TC_SEQTERM); 1426 mk_re_node(t_string, cn, xzalloc(sizeof(regex_t)*2));
1434 if (!cn) 1427 break;
1435 syntax_error("Empty sequence");
1436 cn->a.n = vn;
1437 break;
1438 1428
1439 case TC_GETLINE: 1429 case TC_FUNCTION:
1440 debug_printf_parse("%s: TC_GETLINE\n", __func__); 1430 debug_printf_parse("%s: TC_FUNCTION\n", __func__);
1441 glptr = cn; 1431 cn->info = OC_FUNC;
1442 expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc; 1432 cn->r.f = newfunc(t_string);
1443 break; 1433 cn->l.n = condition();
1434 break;
1444 1435
1445 case TC_BUILTIN: 1436 case TC_SEQSTART:
1446 debug_printf_parse("%s: TC_BUILTIN\n", __func__); 1437 debug_printf_parse("%s: TC_SEQSTART\n", __func__);
1447 cn->l.n = condition(); 1438 cn = vn->r.n = parse_expr(TC_SEQTERM);
1448 break; 1439 if (!cn)
1440 syntax_error("Empty sequence");
1441 cn->a.n = vn;
1442 break;
1449 1443
1450 case TC_LENGTH: 1444 case TC_GETLINE:
1451 debug_printf_parse("%s: TC_LENGTH\n", __func__); 1445 debug_printf_parse("%s: TC_GETLINE\n", __func__);
1452 next_token(TC_SEQSTART /* length(...) */ 1446 glptr = cn;
1453 | TS_OPTERM /* length; (or newline)*/ 1447 expected_tc = TS_OPERAND | TS_UOPPRE | TS_BINOP | term_tc;
1454 | TC_GRPTERM /* length } */ 1448 break;
1455 | TC_BINOPX /* length <op> NUM */ 1449
1456 | TC_COMMA /* print length, 1 */ 1450 case TC_BUILTIN:
1457 ); 1451 debug_printf_parse("%s: TC_BUILTIN\n", __func__);
1458 rollback_token(); 1452 cn->l.n = condition();
1459 if (t_tclass & TC_SEQSTART) { 1453 break;
1460 /* It was a "(" token. Handle just like TC_BUILTIN */ 1454
1461 cn->l.n = condition(); 1455 case TC_LENGTH:
1462 } 1456 debug_printf_parse("%s: TC_LENGTH\n", __func__);
1463 break; 1457 next_token(TC_SEQSTART /* length(...) */
1464 } 1458 | TS_OPTERM /* length; (or newline)*/
1459 | TC_GRPTERM /* length } */
1460 | TC_BINOPX /* length <op> NUM */
1461 | TC_COMMA /* print length, 1 */
1462 );
1463 rollback_token();
1464 if (t_tclass & TC_SEQSTART) {
1465 /* It was a "(" token. Handle just like TC_BUILTIN */
1466 cn->l.n = condition();
1465 } 1467 }
1468 break;
1466 } 1469 }
1467 } /* while() */ 1470 } /* while() */
1468 1471