summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/checkauto.l42
-rw-r--r--src/cregex.c14
2 files changed, 22 insertions, 34 deletions
diff --git a/src/checkauto.l b/src/checkauto.l
index c42d97cf..b61c7cb3 100644
--- a/src/checkauto.l
+++ b/src/checkauto.l
@@ -1,4 +1,4 @@
-/* Check for illegal return/break/continue usage inside a STC-lib c_auto* block (RAII).
+/* Check for illegal return/break/continue usage inside a STC-lib c_AUTO* block (RAII).
* Copyright Tyge Løvset, (c) 2022.
*/
%{
@@ -53,7 +53,12 @@ c_with |
c_scope |
c_defer |
c_autodrop |
-c_auto { block_type = AUTO; state = BRACES; }
+c_auto |
+c_WITH |
+c_SCOPE |
+c_DEFER |
+c_AUTODROP |
+c_AUTO { block_type = AUTO; state = BRACES; }
\( { if (state == BRACES) ++braces_lev; }
\) { if (state == BRACES && --braces_lev == 0) {
state = BRACESDONE;
@@ -61,8 +66,8 @@ c_auto { block_type = AUTO; state = BRACES; }
}
if { if (state == BRACESDONE) {
if (block_type == AUTO) {
- printf("%s:%d: warning: 'if' after c_auto* not enclosed in curly braces.\n"
- " Make sure to enclose 'if - else' statement in { } after c_auto*.\n",
+ printf("%s:%d: warning: 'if' after c_AUTO* not enclosed in curly braces.\n"
+ " Make sure to enclose 'if - else' statement in { } after c_AUTO*.\n",
fname, yylineno);
++warnings;
}
@@ -78,41 +83,24 @@ if { if (state == BRACESDONE) {
\{ { if (state != BRACES) { block[++block_lev] = block_type; state = NORMAL; } }
\} { if (state != BRACES) block_type = block[--block_lev]; }
return { if (block_type == AUTO) {
- printf("%s:%d: error: 'return' used inside a c_auto* scope.\n"
- //" Use 'c_breakauto' to exit the current c_auto* scope.\n"
+ printf("%s:%d: error: 'return' used inside a c_AUTO* scope.\n"
+ " Use 'continue' to exit the current c_AUTO* scope before return.\n"
, fname, yylineno);
++errors;
} else if (block_type & AUTO) {
- printf("%s:%d: error: 'return' used in a loop inside a c_auto* scope.\n"
- //" Use 'break' to exit loops, then 'c_breakauto' to exit c_auto*.\n"
+ printf("%s:%d: error: 'return' used in a loop inside a c_AUTO* scope.\n"
+ " Use 'break' to exit loop, then 'continue' to exit c_AUTO*.\n"
, fname, yylineno);
++errors;
}
}
break { if (block_type == AUTO) {
- printf("%s:%d: error: 'break' used inside a c_auto* scope.\n"
- //" Use 'c_breakauto' to exit the current c_auto* scope.\n"
+ printf("%s:%d: error: 'break' used inside a c_AUTO* scope.\n"
+ " Use 'continue' to exit the current c_AUTO* scope.\n"
, fname, yylineno);
++errors;
}
}
-continue { if (block_type == AUTO) {
- printf("%s:%d: warning: 'continue' used inside a c_auto* scope.\n"
- " It will only break out of the current c_auto* scope.\n"
- //" Use 'c_breakauto' instead to make it explicit.\n"
- , fname, yylineno);
- ++warnings;
- }
- }
-c_breakauto { if (block_type != AUTO) {
- /*
- printf("%s:%d: warning: 'c_breakauto' used outside a c_auto* scope.\n"
- " Did you mean 'continue' instead?"
- , fname, yylineno);
- ++warnings;
- */
- }
- }
{ID} ;
\n ++yylineno;
. ;
diff --git a/src/cregex.c b/src/cregex.c
index d19b063f..e59e21a4 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -530,7 +530,7 @@ _optimize(_Parser *par, _Reprog *pp)
*/
intptr_t ipp = (intptr_t)pp;
size_t size = sizeof(_Reprog) + (size_t)(par->freep - pp->firstinst)*sizeof(_Reinst);
- _Reprog *npp = (_Reprog *)c_realloc(pp, size);
+ _Reprog *npp = (_Reprog *)c_REALLOC(pp, size);
ptrdiff_t diff = (intptr_t)npp - ipp;
if ((npp == NULL) | (diff == 0))
@@ -816,10 +816,10 @@ _regcomp1(_Reprog *progp, _Parser *par, const char *s, int cflags)
/* get memory for the program. estimated max usage */
const size_t instcap = 5 + 6*strlen(s);
- _Reprog* pp = (_Reprog *)c_realloc(progp, sizeof(_Reprog) + instcap*sizeof(_Reinst));
+ _Reprog* pp = (_Reprog *)c_REALLOC(progp, sizeof(_Reprog) + instcap*sizeof(_Reinst));
if (pp == NULL) {
par->error = CREG_OUTOFMEMORY;
- c_free(progp);
+ c_FREE(progp);
return NULL;
}
pp->flags.icase = (cflags & CREG_C_ICASE) != 0;
@@ -870,7 +870,7 @@ _regcomp1(_Reprog *progp, _Parser *par, const char *s, int cflags)
pp->nsubids = (unsigned)par->cursubid;
out:
if (par->error) {
- c_free(pp);
+ c_FREE(pp);
pp = NULL;
}
return pp;
@@ -1105,7 +1105,7 @@ _regexec2(const _Reprog *progp, /* program to run */
_Relist *relists;
/* mark space */
- relists = (_Relist *)c_malloc(2 * _BIGLISTSIZE*sizeof(_Relist));
+ relists = (_Relist *)c_MALLOC(2 * _BIGLISTSIZE*sizeof(_Relist));
if (relists == NULL)
return -1;
@@ -1115,7 +1115,7 @@ _regexec2(const _Reprog *progp, /* program to run */
j->reliste[1] = relists + 2*_BIGLISTSIZE - 2;
rv = _regexec1(progp, bol, mp, ms, j, mflags);
- c_free(relists);
+ c_FREE(relists);
return rv;
}
@@ -1281,6 +1281,6 @@ cregex_replace_pattern_ex(const char* pattern, const char* input, const char* re
void
cregex_drop(cregex* self) {
- c_free(self->prog);
+ c_FREE(self->prog);
}
#endif