home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3736 < prev    next >
Encoding:
Text File  |  1992-07-22  |  1.8 KB  |  44 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!informatik.tu-muenchen.de!rommel
  3. From: rommel@Informatik.TU-Muenchen.DE (Kai-Uwe Rommel)
  4. Subject: Re: EMX library bug.
  5. References: <ReiBoB5w164w@dvss.UUCP> <1992Jul22.185306.10692@ampex.com>
  6. Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
  7. Organization: Technische Universitaet Muenchen, Germany
  8. Date: Thu, 23 Jul 1992 07:33:07 GMT
  9. Message-ID: <1992Jul23.073307.10996@Informatik.TU-Muenchen.DE>
  10. Lines: 32
  11.  
  12. In article <1992Jul22.185306.10692@ampex.com> cjensen@ampex.com (Colin Jensen) writes:
  13. >In article <ReiBoB5w164w@dvss.UUCP> dvss!jtroy@udel.edu (Jay Troy) writes:
  14. >>I think I've discovered an EMX library bug.  The standard library function
  15. >>strtok causes an access violation in every combination that I've tried.  The
  16. >>following simple C program illustrates this problem:
  17. >
  18. >>    char *ch = "3.4 4.1";
  19. >>    strcpy(temp, strtok(ch," "));
  20. >
  21. >I don't know anything about EMX, but your code is certainly problematic.
  22. >A C compiler is free to store strings constants like "3.4 4.1" in 
  23. >read-only memory [hence their name].  Since strtok will try to write 
  24. >into that memory, an access violation should be expected.
  25. >
  26. >To be portable, you need to copy that string either into an automatic variable
  27. >or copy it into some malloc'ed memory.
  28. >
  29. >Under UNIX, you can pass gcc the option -fwritable-strings to tell gcc you
  30. >really want to be able to write into string constants.  Perhaps this would
  31. >solve your problem with EMX.
  32. >-- 
  33. >Colin Jensen (cjensen@ampex.com)
  34.  
  35. Yes, -fwritable-strings solves this problem. Try it.
  36.  
  37. Kai Uwe Rommel
  38.  
  39. /* Kai Uwe Rommel --- rommel@informatik.tu-muenchen.de */
  40.  
  41. DOS ... is still a real mode only non-reentrant interrupt
  42. handler, and always will be.                -Russell Williams
  43.  
  44.