Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid backslash escape in string #2860

Closed
vicuna opened this issue Jun 25, 2004 · 2 comments
Closed

Invalid backslash escape in string #2860

vicuna opened this issue Jun 25, 2004 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 25, 2004

Original bug ID: 2860
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

The Objective Caml compiler, version 3.08+alpha0 (2004-06-22)
Standard library directory: /usr/local/adm/src/caml/lib/ocaml
me donne cet avertissement:
/usr/local/adm/src/caml/bin/ocamlc.opt -warn-error A -g -pp "/usr/local/adm/src/caml/bin/camlp4r -I ." -I . -I /usr/local/adm/src/caml/lib/ocaml/camlp4 -c cstr.ml
Warning: char 1246, Invalid backslash escape in string
Warning: char 1123, Invalid backslash escape in string

Les caractères 1123 et 1246 sont ici:
value char_downcase =
-------------^
et ici
value char_eq (c1 : char) c2 = c1 = c2;
-------------^

Bon, je me demande si je n'ai pas une longue chaîne de plus de 1246
caractères, mais les seules de ce fichier sont:
13 lines matching """ in buffer cstr.ml.
1: (* #load "./schemeids.cmo" )
2: (
#load "./string_ids.cmo" )
3: (
#load "pa_scheme.cmo" *)
17:#load "string_macros.cmo";
34:external length : string -> int = "%string_length";
40: (List.fold_left ^ "Illegal substring "
41: [what; " spec: "; indexes; " in "; module_name; "."; caller; "\n"; s])
43: if start < 0 then fail "start" (string_of_int start)
44: else if end_ > length s then fail "end" (string_of_int end_)
46: fail "start/end" (string_of_int start ^ "/" ^ string_of_int end_)
50:external create : int -> string = "caml_create_string";
51:external unsafe_fill : string -> int -> int -> char -> unit = "caml_fill_string" "noalloc";
61: string -> int -> string -> int -> int -> unit = "caml_blit_string" "noalloc";

D'autre part, les seuls backslashs sont:
2 lines matching "\\" in buffer cstr.ml.
40: (List.fold_left ^ "Illegal substring "
41: [what; " spec: "; indexes; " in "; module_name; "."; caller; "\n"; s])

Donc je ne sais pas corriger ce qui provoque l'avertissement.

(Pour tester sur mes sources, prendre la version CVS de Cstr sur
camlcvs: http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/cash/cstr/)

Bruno.

@vicuna
Copy link
Author

vicuna commented Jun 25, 2004

Comment author: administrator

Warning: char 1246, Invalid backslash escape in string
Warning: char 1123, Invalid backslash escape in string

L'erreur ne se trouve pas dans cstr.ml, mais dans string_macros.ml.
Bien sur, la position de l'erreur dans cstr.ml n'est pas tres bien definie...

Tu peux voir le probleme en faisant:

/usr/local/adm/src/caml/bin/camlp4r -I . pr_o.cmo cstr.ml >foobar.ml

Le bug se trouve dans les definitions de upper_string et lower_string.
Comme les chaines en questions sont destinees a repasser dans le lexeur,
il faut les encoder avec String.escaped.

-- Damien

@vicuna vicuna closed this as completed Jun 25, 2004
@vicuna
Copy link
Author

vicuna commented Jun 28, 2004

Comment author: administrator

J'ai testé avec
http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/cash/cstr/cstr.ml (ocamlc
-pp "camlp4r" en commentant un #load et définissant à la main 2
fonctions) et je n'obtiens pas ce warning. Si je mets un "\p" quelque
part dans une chaîne, j'obtiens bien le warning avec la bonne
position, en numéro de char.

J'ai tout de même changé pour que le warning apparaisse avec le numéro
de ligne.

Je reste preneur de warnings avec positions fantaisistes: ce sont des
bugs qui pourraient rester du changement des locations de
camlp4.

-- Michel

Bruno.Verlyck@inria.fr wrote/écrivait (Fri, Jun 25, 2004 at 07:50:57PM +0200):

The Objective Caml compiler, version 3.08+alpha0 (2004-06-22)
Standard library directory: /usr/local/adm/src/caml/lib/ocaml
me donne cet avertissement:
/usr/local/adm/src/caml/bin/ocamlc.opt -warn-error A -g -pp "/usr/local/adm/src/caml/bin/camlp4r -I ." -I . -I /usr/local/adm/src/caml/lib/ocaml/camlp4 -c cstr.ml
Warning: char 1246, Invalid backslash escape in string
Warning: char 1123, Invalid backslash escape in string

Les caractères 1123 et 1246 sont ici:
value char_downcase =
-------------^
et ici
value char_eq (c1 : char) c2 = c1 = c2;
-------------^

[...]

(Pour tester sur mes sources, prendre la version CVS de Cstr sur
camlcvs: http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/cash/cstr/)

Bruno.

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant