[ros-kernel] String Display Error

Nate DeSimone desimn at rpi.edu
Wed Jan 28 20:29:06 CET 2004


Thats not what I mean.  Let me take this back to the beginning.  
Consider the following piece of code:

//test.cpp
//Test the behavior of outputing the character after the end of a string
//Author: Nate DeSimone

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string somestring = "Test String";

    //try accessing using an index of the string's size, 1 past the end 
of the string
    int asciicode = somestring[somestring.size()];

    cout << "Character after the end of somestring = \'" << 
somestring[somestring.size()] << "\'" << endl;
    cout << "ASCII Code for this character is: " << asciicode << endl;
}

    Simple Right?  All it does it display the character after the end of 
the string.  Yet look at the different outputs produced by ReactOS and 
Windows and Linux (screenshots attached.)    All 3 platforms agree that 
a string created using the string class from the standard libary is 
terminated with a zero, which is standard behavior.  The ASCII code 0 is 
the control character ^@ and has no real character assigned to it, so 
windows and linux display it as a blank (windows actually puts a space 
linux puts nothing), however ReactOS displays a box character instead of 
a space.  Now I don't know if there is any "standard" for displaying 
this character, but I think that reactos should behave like Windows when 
displaying text on the console.  Just my thoughts.

Thanks,

Nate DeSimone


>While pages are zero filled by the zero page thread before they are passed
>to processes via Nt/ZwAllocateVirtualMemory, you aren't guaranteed a zero
>filled buffer if you use, say, the heap functions to allocate memory.  So, I
>do not think there is some missing behavior in ReactOS.
>
>-----Original Message-----
>From: ros-kernel-bounces at reactos.com [mailto:ros-kernel-bounces at reactos.com]
>On Behalf Of Nate DeSimone
>Sent: Wednesday, January 28, 2004 2:20 PM
>To: ReactOS Kernel List
>Subject: Re: [ros-kernel] String Display Error
>
>Actually there has been consistent behavior in the case of both 
>platforms, I think the reason for this is because if I remember 
>correctly all strings a zero terminated, so it really doesn't run past 
>the end of the string, its just running past the useful part of it, so 
>when Windows reads that zero it just puts a blank space but ReactOS puts 
>a box.
>
>  
>
>>Zitat von Nate DeSimone <desimn at rpi.edu>:
>>
>> 
>>
>>    
>>
>>>I figured out the problem.  It was in fact a bug in my code, when I was
>>>combining two strings I actually went 1 character over the end of the
>>>smaller string, due to having a <= instead of a < in my for loop's
>>>condition, and I would never have even thought I looking more closely at
>>>that had it not been for ReactOS, of course I'm sure that if I made that
>>>mistake other people did too so it might be worthwhile to make ReactOS
>>>behave like Windows when it encounters that error.
>>>   
>>>
>>>      
>>>
>>Hi,
>>IMHO there is no normal behavior since the memory contents beyond the
>>    
>>
>string is
>  
>
>>purely random and also may not belong to the application itself. Thus the
>>behavior cannot be forseen (from segementation violation to printing out
>>    
>>
>random
>  
>
>>characters)
>>
>>regards,
>>
>>--
>>Johannes Anderwald
>>
>>_______________________________________________
>>Ros-kernel mailing list
>>Ros-kernel at reactos.com
>>http://reactos.com/mailman/listinfo/ros-kernel
>>
>>
>> 
>>
>>    
>>
>
>_______________________________________________
>Ros-kernel mailing list
>Ros-kernel at reactos.com
>http://reactos.com/mailman/listinfo/ros-kernel
>
>
>_______________________________________________
>Ros-kernel mailing list
>Ros-kernel at reactos.com
>http://reactos.com/mailman/listinfo/ros-kernel
>
>
>  
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: linux.png
Type: image/png
Size: 18649 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040128/702ef3a0/linux-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reactos.png
Type: image/png
Size: 9804 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040128/702ef3a0/reactos-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: windows.png
Type: image/png
Size: 13354 bytes
Desc: not available
Url : http://reactos.com:8080/pipermail/ros-kernel/attachments/20040128/702ef3a0/windows-0001.png


More information about the Ros-kernel mailing list