Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
On Thursday 02 Jun 2005 20:18, Curtis L. Olson wrote: > Ampere K. Hardraade wrote: > >On June 1, 2005 07:02 pm, Andy Ross wrote: > >>This isn't fixable without relatively major surgery, so for > >> now I think you're stuck. Maybe Melchior's suggestion of > >> storing your data in Nasal space is the best one for the > >> moment. > > > >Okay. I think I came up with something using Nasal. =) > > > >Objects in Nasal seems to get passed/assigned by reference. > > So I wrote myself a medium object, passed two I/O buffers to > > it, and have the buffers swap by the medium periodically by > > calling the function settimer(medium.update, 0). It seems to > > work, and seems to be better than using the property tree as > > well. > > Hehe, when is your first release of NasalOS? :-) > > Curt. How about calling the shell (g)nash? :) LeeE ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Ampere K. Hardraade wrote: On June 1, 2005 07:02 pm, Andy Ross wrote: This isn't fixable without relatively major surgery, so for now I think you're stuck. Maybe Melchior's suggestion of storing your data in Nasal space is the best one for the moment. Okay. I think I came up with something using Nasal. =) Objects in Nasal seems to get passed/assigned by reference. So I wrote myself a medium object, passed two I/O buffers to it, and have the buffers swap by the medium periodically by calling the function settimer(medium.update, 0). It seems to work, and seems to be better than using the property tree as well. Hehe, when is your first release of NasalOS? :-) Curt. -- Curtis Olsonhttp://www.flightgear.org/~curt HumanFIRST Program http://www.humanfirst.umn.edu/ FlightGear Project http://www.flightgear.org Unique text:2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
On June 1, 2005 07:02 pm, Andy Ross wrote: > This isn't fixable without relatively major surgery, so for now I > think you're stuck. Maybe Melchior's suggestion of storing your data > in Nasal space is the best one for the moment. Okay. I think I came up with something using Nasal. =) Objects in Nasal seems to get passed/assigned by reference. So I wrote myself a medium object, passed two I/O buffers to it, and have the buffers swap by the medium periodically by calling the function settimer(medium.update, 0). It seems to work, and seems to be better than using the property tree as well. Ampere ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Curtis L. Olson wrote: Andy Ross wrote: It does if you don't specify a length: fixing this requires changing every spot in the code where a "string" was read from or written to a property to make the code handle the length properly. It's not hard, but it's a huge amount of work (and probably not worth it, as you can store arbitrary byte buffers as Nasal objects anyway). I'd prefer adding a new property type (i.e. byte array?) before diverging from the commonly understood and accepted meaning of a "C string". Forcing the calling layer to manage string length *every* place a string is used would be a huge mess I think ... that's why we special case "string" in the first place ... it means an array of bytes terminated with a null, and it's very useful! Okay, okay. I'll let it go. It's also hard to decide how to convert such a byte array to an int/double/bool or even string type. Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Andy Ross wrote: It does if you don't specify a length: fixing this requires changing every spot in the code where a "string" was read from or written to a property to make the code handle the length properly. It's not hard, but it's a huge amount of work (and probably not worth it, as you can store arbitrary byte buffers as Nasal objects anyway). I'd prefer adding a new property type (i.e. byte array?) before diverging from the commonly understood and accepted meaning of a "C string". Forcing the calling layer to manage string length *every* place a string is used would be a huge mess I think ... that's why we special case "string" in the first place ... it means an array of bytes terminated with a null, and it's very useful! Curt. -- Curtis Olsonhttp://www.flightgear.org/~curt HumanFIRST Program http://www.humanfirst.umn.edu/ FlightGear Project http://www.flightgear.org Unique text:2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
I wrote: > > The property system does not support arbitrary byte arrays in the > > string value. The SGPropertyNode::setStringValue() interface > > supports only C strings (a char* with no length), which are always > > nul terminated. > > Well, char* doesn't require it to be NULL terminated and > strlen()(and strcpy) is only used in one function. It does if you don't specify a length: fixing this requires changing every spot in the code where a "string" was read from or written to a property to make the code handle the length properly. It's not hard, but it's a huge amount of work (and probably not worth it, as you can store arbitrary byte buffers as Nasal objects anyway). Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Andy Ross wrote: You're right. The property system does not support arbitrary byte arrays in the string value. The SGPropertyNode::setStringValue() interface supports only C strings (a char* with no length), which are always nul terminated. Well, char* doesn't require it to be NULL terminated and strlen()(and strcpy) is only used in one function. So in theory it might not be too hard to switch from string to raw, however this requires the length to be specified when assigning a property. Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Andy Ross wrote: My guess is that the property tree doesn't care either, and it's simply the output routine that is truncating the string due to the embedded null. Is there some sample code to exhibit the problem? Hmm, that makes sense, why should Nasal or the property care in the first place. Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Ampere K. Hardraade wrote: > Andy Ross wrote: > > Is there some sample code to exhibit the problem? > > Do you mean something like this? Yup, that will do it. :) You're right. The property system does not support arbitrary byte arrays in the string value. The SGPropertyNode::setStringValue() interface supports only C strings (a char* with no length), which are always nul terminated. This isn't fixable without relatively major surgery, so for now I think you're stuck. Maybe Melchior's suggestion of storing your data in Nasal space is the best one for the moment. Also, a note about your sample code: the strc() function is semi-deprecated. The current Nasal interpreter allows you to get the byte in a string using just str[i] instead of strc(str, i). The strc() interface is likely to come back as part of a utf8 package for doing multibyte handling, but for single bytes you should probably be using the array index notation. Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
On June 1, 2005 04:23 pm, Andy Ross wrote: > My guess is that the property tree doesn't care either, and it's > simply the output routine that is truncating the string due to the > embedded null. Is there some sample code to exhibit the problem? > > Andy Do you mean something like this? # ** ** ** ** ** str = chr(01) ~ chr(80) ~ chr(194) ~ chr(0) ~ chr(0) ~ chr(0); node = props.globals.getNode("/experiment", 1); print ("Writing the following characters to the property tree:"); for (i = 0; i < size(str); i = i + 1){ print(strc(str, i)); } node.setValue(str); tmp = node.getValue(); print ("The following characters were retrieved from the property tree:"); for (j = 0; j < size(tmp); j = j + 1){ print(strc(tmp, j)); } # ** ** ** ** ** Ampere ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Erik Hofman wrote: > I don';t think the property tree cares much, I expect this is a > string handling "problem" in Nasal because it is written in C(++). No, Nasal strings are arbitrary byte streams. You can have embedded zeros. I understood the question to be about the property *name*, not the contents, but that seems to have been incorrect. (Ampere had reported a bug to me earlier about not being able to have a property node name of "0", and I thought this was an extension of that issue, but I was wrong). My guess is that the property tree doesn't care either, and it's simply the output routine that is truncating the string due to the embedded null. Is there some sample code to exhibit the problem? Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Ampere K. Hardraade wrote: Well, last evening I experimented with putting information one byte at a time to the property tree as opposed to putting a string, but I don't see this as a way out because it is not scalable. The running time can reach thousands, if not tens of thousands easily. You don't say what higher level problem you are trying to solve here. Perhaps if you take a step back and think about that, you could come up with a simpler, or easier, or more natural way to solve the problem. Regards, Curt. -- Curtis Olsonhttp://www.flightgear.org/~curt HumanFIRST Program http://www.humanfirst.umn.edu/ FlightGear Project http://www.flightgear.org Unique text:2f585eeea02e2c79d7b1d8c4963bae2d ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
> I don';t think the property tree cares much, I expect this is a string > handling "problem" in Nasal because it is written in C(++). Actually, it is the otherway around: Nasal doesn't care, while the property tree does. I hope Nasal stays that way. > Oh wait, Ampere is actually trying to put "\0" etc into a string (or > default) property? That can't be done. You could however define the > properties to be of type double or int and assign "property=0". Well, last evening I experimented with putting information one byte at a time to the property tree as opposed to putting a string, but I don't see this as a way out because it is not scalable. The running time can reach thousands, if not tens of thousands easily. Ampere ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Andy Ross wrote: Property names should be ASCII strings, by convention at least if not by force. ASCII strings don't contain nuls. Oh wait, Ampere is actually trying to put "\0" etc into a string (or default) property? That can't be done. You could however define the properties to be of type double or int and assign "property=0". Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Ampere K. Hardraade wrote: I have been experimenting with Nasal lately. The focus of my experiment is to have one Nasal script communicate with another using the property tree. In an attempt of communication, a Nasal script of mine placed the following stream of characters to the property tree: 1, 80, 194, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 6, 207, 128, 174, 239, 0, 0, 127, 0, 0, 6, 207, 128, 174, 239, 0, 0, 0, 0, 0, 20, 0, 2, 0, 15, 0, 0, 0, 0 Unfortunately, the property tree cuts off everything after the first character \0. My questions are: Why doesn't the property tree except the \0 character? Is there any chance that it can accept the \0 character? I don';t think the property tree cares much, I expect this is a string handling "problem" in Nasal because it is written in C(++). Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Cannot put character with ascii code 0 into the property tree
Ampere K. Hardraade wrote: > Why doesn't the property tree except the \0 character? > Is there any chance that it can accept the \0 character? The zero is the ASCII NUL character, which has been used as the "end of string" marker since the beginning of time (which we all know was at midnight GMT on December 31st 1969). This convention is so prevalent that every language encoding known to man avoids the use of this byte for compatibility with C code that expects to read it as the end of the string. Property names should be ASCII strings, by convention at least if not by force. ASCII strings don't contain nuls. Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
[Flightgear-devel] Cannot put character with ascii code 0 into the property tree
I have been experimenting with Nasal lately. The focus of my experiment is to have one Nasal script communicate with another using the property tree. In an attempt of communication, a Nasal script of mine placed the following stream of characters to the property tree: 1, 80, 194, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 6, 207, 128, 174, 239, 0, 0, 127, 0, 0, 6, 207, 128, 174, 239, 0, 0, 0, 0, 0, 20, 0, 2, 0, 15, 0, 0, 0, 0 Unfortunately, the property tree cuts off everything after the first character \0. My questions are: Why doesn't the property tree except the \0 character? Is there any chance that it can accept the \0 character? Thanks in advance, Ampere ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d