developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 12 years ago

Closed 12 years ago

#697 closed bug (fixed)

jIniFileModifier adds unusefull "\n"

Reported by: doubleface Owned by: doubleface
Priority: normal Milestone: Jelix 1.1 beta 1
Component: jelix:utils Version: trunk
Severity: minor Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

If you load a ini file and save it n times, you get n empty lines between the original lines :

"[SECTION]
value1=0
value2=0"

becomes

"[SECTION]

value1=0

value2=0

"

and becomes

"[SECTION]


value1=0


value2=0


"

after each jInifile::save().

See the joined patch

Attachments (1)

jInifileModifier.patch (1.1 KB) - added by doubleface 12 years ago.

Download all attachments as: .zip

Change History (2)

Changed 12 years ago by doubleface

comment:1 Changed 12 years ago by laurentj

  • Component changed from jelix to jelix:utils
  • Milestone set to Jelix 1.1 beta 1
  • Resolution set to fixed
  • review changed from review? to review-
  • Status changed from new to closed

In fact, the problem is not these added line break but the function used to read each line of the file (file() function). It seems you edit your ini file with an editor which generates \r or \r\n instead of single \n. So by removing them in your patch, you completely broke the behavior of the class for developers who edit their ini file with \n as line breaks (If you run unit-tests, you can see your error ;-)).

So I just changed the function and replaced ot by a file_get_contents + preg_split.

Note: See TracTickets for help on using tickets.