Waitrud Weber’s blog

things and reminders for memories

CodeAnalyzer: html: It matches between start tag and end tag.

For the match of start and end tags in html, we can be confused of skipping space and detecting '/'in C.

1   - -
2

main.cpp  Tue Apr 19 08:30:06 2022

...

256 ://
257 :int suits_tagname( char* k_buffer, char* tagname ) {
258 :    int kac, tac;
259 :    char kc, tc;
260 :    int fk, ft;
261 :    int match;
262 :    printf("int suits_tagname( char* k_buffer, char* tagname ) starts.\r\n");
263 :
264 :    match =0;
265 :    fk = 0;
266 :    ft = 0;
267 :    kac = array_count ( k_buffer );
268 :    tac = array_count ( tagname );
269 :    for ( int i=0; i<kac; i++ ) {
270 :        kc = k_buffer[i];
271 :
272 :        if ( fk == 1 && kc == ' ' )
273 :            break;
274 :
275 :        if ( fk == 0 && kc != ' ' )
276 :            fk++;
277 :
278 :
279 :        if ( fk==2 ) {
280 :            for ( int j=0; j<tac; j++ ) {
281 :                tc = tagname[j];
282 :
283 :                if ( ft == 0 && tc == ' ' ) {
284 :                    ft++;
285 :                    break;
286 :                }
287 :
288 :                if ( ft == 0 && tc != ' ' )
289 :                    ft++;
290 :
291 :                if ( ft == 1 ) {
292 :                    printf("|%c| and |%c|\r\n", kc, tc );
293 :                }
294 :
295 :                if ( ft == 1 && kc == tc ) {
296 :                    match++;
297 :                    break;
298 :                }
299 :
300 :                if ( ft == 1 && kc != tc ) {
301 :                    printf("int suits_tagname( char* k_buffer, char* tagname ) return -1.\r\n");
302 :                    return -1;
303 :                }
304 :
305 :
306 :                if ( ft == 0 && kc != ' ' )
307 :                    ft++;
308 :
309 :            }
310 :        }
311 :
312 :        // k_buffer first letter is '/'
313 :        if ( fk==1 && kc == '/' ) {
314 :            fk++;
315 :            printf("fk = %d\r\n", fk);
316 :        }
317 :
318 :        if ( ft == 2 ) break;
319 :    }
320 :
321 :    if ( match > 0 ) {
322 :        printf("match %d \r\n", match);
323 :        printf("int suits_tagname( char* k_buffer, char* tagname ) return 1.\r\n");
324 :        return 1;
325 :    }
326 :
327 :    printf("int suits_tagname( char* k_buffer, char* tagname ) ends.\r\n");
328 :    return -1;
329 :}

   
3 key_buffer |&gt; .\winmain_001.exe| is becoming the between possible.
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) starts.
We found the |>| index 30 fp|1988336744|.
key_buffer |br /|
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) returns 1.
k_buffer |br /| is becoming the end tag inside possible for p.
key_buffer |&gt; .\winmain_001.exe| is still becoming the between possible for p.
sfp->index 30 / sfp->file_end_index 1084
int suits_tagname( char* k_buffer, char* tagname ) starts.
int suits_tagname( char* k_buffer, char* tagname ) ends.
We found the |<| index 43 fp|1988336744|.
key_buffer |&gt; .\winmain_001.exe>file_size:-1| is becoming the between possible.
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) starts.
We found the |>| index 46 fp|1988336744|.
key_buffer |/p|
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) returns 1.
k_buffer |/p| is becoming the end tag inside possible for p.
key_buffer |&gt; .\winmain_001.exe>file_size:-1| is still becoming the between possible for p.
sfp->index 46 / sfp->file_end_index 1084
int suits_tagname( char* k_buffer, char* tagname ) starts.
fk = 2
|p| and |p|
match 1
int suits_tagname( char* k_buffer, char* tagname ) return 1.
int get_between( char* key_buffer, int max_buffer, HTMLTAG* html, STRUCT_FILE* sfp ) returns 1.
html|00761180|
   
4      
5      
6