b4n commented on this pull request.


> +/*
+*   FUNCTION DEFINITIONS
+*/
+static void findAutoItTags (void)
+{
+       vString *name = vStringNew ();
+       const unsigned char *line;
+
+       while ((line = readLineFromInputFile ()) != NULL)
+       {
+               const unsigned char* p = line;
+               if (p [0] == '#')
+               {
+                       /* min. string "#region" > 7 */
+                       if ((p [1] == 'R' || p [1] == 'r') &&
+                               strlen ((const char *) p) > 8 &&

C strings have a last element with value `0`, which is actually delimiting the 
end of the string. `strlen(str)` is just going through `str` to find at which 
offset `0` is found (it could basically be implemented as `for (len = 0; 
str[len] != 0; len++);`).

Anyway, this means that so long as none of the characters before the subscript 
has value `0`, the next one is a valid subscript -- it just can be the last one 
if it has value `0`.  Thus, as you check the values of subscripts successively 
against a defined set *not including* `0`, you're sure that you won't try 
subscripting past the end of the string, otherwise your tests would have to be 
false already anyway.
So if `p[1]` is either `'R'` or `'r'` (so not `0`), `p[2]` has to be a valid 
subscript.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1752#discussion_r207886958

Reply via email to