Ticket #1180 (closed bug: done)

Opened 12 years ago

Last modified 10 years ago

examples/nci/ls.pir prints only lines with one character each

Reported by: moritz Owned by: NotFound
Priority: normal Milestone:
Component: none Version: 1.7.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:


Currently (r42217) examples/nci/ls.pir gives a weird output, at most one character per line, instead of giving me a directory listing as advertised in the comments in that file.

$ ./parrot examples/nci/ls.pir |hexdump -C
00000000  02 0a 0a 0a 0a 0a 0c 0a  10 0a 16 0a 18 0a 1d 0a  |................|
00000010  1d 0a 1f 0a 24 0a 25 0a  27 0a 2b 0a 2b 0a 2d 0a  |....$.%.'.+.+.-.|
00000020  30 0a 32 0a 32 0a 39 0a  3b 0a 3e 0a 41 0a 48 0a  |;.>.A.H.|
00000030  48 0a 4a 0a 50 0a 59 0a  59 0a 5f 0a 60 0a 66 0a  |H.J.P.Y.Y._.`.f.|
00000040  6c 0a 72 0a 76 0a 79 0a  7b 0a 7e 0a 7f 0a 7f 0a  |l.r.v.y.{.~.....|

This is Debian GNU/Linux 5.0, amd64. Parrot is built with --optimize.

Change History

  Changed 11 years ago by NotFound

  • status changed from new to assigned
  • owner set to NotFound

Fixed in 2b1c3369fb02e339bbbb6c3ddfb435fb692053fb but the values used for the struct are probably architecture dependent, needs review.

  Changed 11 years ago by NotFound

With other fix it works in i386 and amd64 under linux. The dirent structure is not fully standarized, so in order to make it more portable it needs platform checks and setting the structure in different ways.

I think it's too much for a simple example, so I'm going to add a comment about the lack of portability and close the ticket if no one opposes in a few days.

  Changed 11 years ago by NotFound

  • status changed from assigned to closed
  • resolution set to fixed

No objections in several days. Added note about platform dependence in ec3d188 Closing ticket,

follow-up: ↓ 5   Changed 11 years ago by coke

  • status changed from closed to reopened
  • resolution fixed deleted
As I reported on IRC, this dies on darwin:

$ ./parrot examples/nci/ls.pir

oInvalid character for UTF-8 encoding

current instr.: '_main' pc 106 (examples/nci/ls.pir:58)

in reply to: ↑ 4   Changed 10 years ago by jkeenan

Replying to coke:

Confirmed that this persists on Darwin:

 ./parrot examples/nci/ls.pir


  Changed 10 years ago by NotFound

  • status changed from reopened to closed
  • resolution set to done

After minimal discussion in irc, we agreed that this is not a bug. The example shows a platform dependent usage of NCI, and as such it does not work on all platforms. Adding checks and variants for more platforms will defeat the purpose of being a simple example.

The source explains that fact, and tell on what platforms it's supposed to work.

Closing again.

Note: See TracTickets for help on using tickets.