~mirabilos/mksh/MAIN

« back to all changes in this revision

Viewing changes to expr.c

  • Committer: tg
  • Date: 2023-10-23 20:59:39 UTC
  • Revision ID: tg-20231023205939-44pfbq333nazsrpf
report evalerr with E prefix

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*-
4
4
 * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5
5
 *               2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019,
6
 
 *               2021, 2022
 
6
 *               2021, 2022, 2023
7
7
 *      mirabilos <m@mirbsd.org>
8
8
 *
9
9
 * Provided that these terms and disclaimer and all copyright notices
25
25
#define MKSH_DO_MBI_CTAS
26
26
#include "sh.h"
27
27
 
28
 
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.126 2023/10/06 21:56:48 tg Exp $");
 
28
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.127 2023/10/23 20:59:39 tg Exp $");
29
29
 
30
30
#define EXPRTOK_DEFNS
31
31
#include "exprtok.h"
203
203
                default:
204
204
                        s = opname[(int)es->tok];
205
205
                }
206
 
                kwarnf0(KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO, Tf_sD_s_qs,
207
 
                    es->expression, Tunexpected, s);
 
206
                kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO,
 
207
                    Tf_sD_s_qs, es->expression, Tunexpected, s);
208
208
                break;
209
209
 
210
210
        case ET_BADLIT:
211
211
                if (!strcmp(es->expression, str))
212
 
                        kwarnf0(KWF_PREFIX | KWF_FILELINE | KWF_TWOMSG,
213
 
                            es->expression, Tbadnum);
 
212
                        kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE |
 
213
                            KWF_TWOMSG, es->expression, Tbadnum);
214
214
                else
215
 
                        kwarnf0(KWF_PREFIX | KWF_FILELINE, Tf_sD_s_qs,
216
 
                            es->expression, Tbadnum, str);
 
215
                        kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE,
 
216
                            Tf_sD_s_qs, es->expression, Tbadnum, str);
217
217
                break;
218
218
 
219
219
        case ET_RECURSIVE:
220
 
                kwarnf0(KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO, Tf_sD_s_qs,
 
220
                kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO,
 
221
                    Tf_sD_s_qs,
221
222
                    es->expression, "expression recurses on parameter", str);
222
223
                break;
223
224
 
224
225
        case ET_LVALUE:
225
 
                kwarnf0(KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO, Tf_sD_s_s,
 
226
                kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO,
 
227
                    Tf_sD_s_s,
226
228
                    es->expression, str, "requires lvalue");
227
229
                break;
228
230
 
229
231
        case ET_RDONLY:
230
 
                kwarnf0(KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO, Tf_sD_s_s,
 
232
                kwarnf0(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO,
 
233
                    Tf_sD_s_s,
231
234
                    es->expression, str, "applied to read-only variable");
232
235
                break;
233
236
 
234
237
        default: /* keep gcc happy */
235
238
        case ET_STR:
236
 
                kwarnf(KWF_PREFIX | KWF_FILELINE | KWF_TWOMSG | KWF_NOERRNO,
237
 
                    es->expression, str);
 
239
                kwarnf(KWF_ERR(1) | KWF_PREFIX | KWF_FILELINE | KWF_NOERRNO |
 
240
                    KWF_TWOMSG, es->expression, str);
238
241
                break;
239
242
        }
240
243
        unwind(LAEXPR);