Which number should be assigned to the first column of each line?

I believe it is 0, ie the number of spaces one would have to skip over to reach
the first character. This is the same strategy used by ocaml, eg in the parser
errors.

I have added 0-based to the mentions of column in the ocaml Coccilib man page.
Perhaps the same information will be transmitted to the python page when there
is one...

Would any mailing list reader like to start counting generally with 1 for values like lines and columns?
http://cocci.ekstranet.diku.dk/wiki/doku.php?id=source_location_information


Now I stumble on another interesting implementation detail.


@script:python collection depends on !is_void@
typ << function_declaration.t;
fun << function_declaration.f;
places << function_declaration.p;
@@
for place in places:
    fields = []
    fields.append(fun.ident)
    fields.append(typ)
    fields.append(place.file)
    fields.append(place.line)
    fields.append(place.column + 1)
    result.append(delimiter.join(fields))

@finalize:python@
if result:
result.insert(0, delimiter.join(("function", "return type", "source file", "line", "column")))
   print("\r\n".join(result))
else:
   print("No result for this analysis!")
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: example1b.c
Traceback (most recent call last):
  File "<string>", line 9, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
Failure in collection
Fatal error: exception Pycocci.Pycocciexception


Why does Coccinelle's scripting interface pass numbers as text/strings?

Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to