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
Pervasives.pos_out retourne des informations incorrectes #2335
Comments
Comment author: administrator
D'abord il y a une question de vocabulaire. Le flag Open_append ne dit pas que
Bref, meme en C, l'hypothese que la position courante est egale a la fin du
Moi je propose de documenter le fait que pos_out ne donne pas un resultat -- Damien |
Comment author: administrator Le Mardi 13 Avril 2004 17:29, Damien Doligez a écrit :
|
Comment author: administrator If someone finds a fix where lseek isn't called at each pos_out operation, There is such a fix, but it needs to call lseek at each write operation. Fixed the documentation of pos_out -DD 2004-05-28 |
Original bug ID: 2335
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Bonjour,
Il y a des problèmes avec la sémantique du manuel de Pervasives.pos_out
quand le fichier est ouvert en mode Append.
En effet, supposons que le fichier "/tmp/toto" aie une taille non nulle,
voici ce que répond pos_out :
let out_flags = [Open_wronly ; Open_creat ; Open_append];;
val out_flags : open_flag list = [Open_wronly; Open_creat; Open_append]
let f = open_out_gen out_flags 0o666 "/tmp/toto";;
val f : out_channel =
pos_out f;;
Alors que le manuel déclare que pos out "Returns the current writing position
for the given channel". Ici pos_out devrait donc donner la taille du fichier.
Ceci dit, il ne suffit pas de changer le manuel pour dire que pos_out
implémente la sémantique Unix de lseek(fd,0,SEEK_CUR) car pour un
out_channel la position d'écriture est gérée de manière statique sans
passer par un appel système, ce qui donne le bug suivant :
output_string f "titi\n";;
pos_out f;;
Alors que dans la sémantique Unix ceci devrait répondre "ancienne taille du
fichier + 5". Une proposition de correction est d'appeller lseek pour chaque
appel de pos_out, ou alors de gérer le cas append à chaque écriture.
Nadji
The text was updated successfully, but these errors were encountered: