home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / intervie / 3196 < prev    next >
Encoding:
Text File  |  1992-11-16  |  3.1 KB  |  101 lines

  1. Newsgroups: comp.windows.interviews
  2. Path: sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!ira.uka.de!rz.uni-karlsruhe.de!usenet
  3. From: DAHMS@ifk20.mach.uni-karlsruhe.de (Heribert Dahms)
  4. Subject: Re: Problem with iv3.1-beta3 string class (lacks documentation!)
  5. In-Reply-To: DAHMS@ifk20.mach.uni-karlsruhe.de's message of Fri, 13 Nov 1992 16: 05:16 GMT
  6. Message-ID: <1992Nov16.143842.22052@rz.uni-karlsruhe.de>
  7. Sender: usenet@rz.uni-karlsruhe.de (USENET 'No news is bad news' News System)
  8. Organization: University of Karlsruhe, FRG (Dept. of Mechanical Engineering)
  9. References:  <1992Nov13.160516.19376@rz.uni-karlsruhe.de>
  10. Date: Mon, 16 Nov 1992 14:38:42 GMT
  11. X-News-Reader: VMS NEWS 1.20
  12. Lines: 87
  13.  
  14. In <1992Nov13.160516.19376@rz.uni-karlsruhe.de> DAHMS@ifk20.mach.uni-karlsruhe.de writes:
  15.  
  16. > I'm just porting iv3.1-beta3 to VAX/VMS and got a little problem with the
  17. > string class of InterViews in session.c .
  18. > I miss a complete description of the string class in A.6 of the iv-Manual
  19. > and also in the man pages (which i converted to a VMS help library).
  20. > I try cutting the argv[0] string (program name) from e.g.
  21. >     ifkvs2$dkb0:[interviews31]idemo.exe;7
  22. > first to
  23. >     idemo.exe;7
  24. > which works, but then i want to get
  25. >     idemo
  26. > i.e. the part of the string to the left of the dot (if any), but several
  27. > attempts resulted in keeping
  28. >     idemo.exe;7
  29. > That's obviously no problem with VMS itself, only with the string handling!
  30. > What's wrong?
  31. > Thanks,
  32. > Heribert Dahms    (dahms@ifk20.mach.uni-karlsruhe.de)
  33. > =============================================================================
  34. > Extract of src/lib/interviews/session.c :
  35. > =============================================================================
  36. > /*
  37. >  * Use ICCCM rules to find an application's instance name
  38. >  * from the command line or an environment variable.
  39. >  */
  40. > String* SessionRep::find_name() {
  41. >     String name;
  42. >     if (find_arg(String("-name"), name)) {
  43. >     return new String(name);
  44. >     }
  45. >     const char* res_name = getenv("RESOURCE_NAME");
  46. >     if (res_name != nil) {
  47. >     return new String(res_name);
  48. >     }
  49. >     if (argc_ > 0) {
  50. >     String s(argv_[0]);
  51. > #ifdef VMS        // H. Dahms  12.11.92
  52. >     int slash = s.rindex(']');
  53. > #else
  54. >     int slash = s.rindex('/');
  55. > #endif
  56. >     if (slash >= 0) {
  57. >         s = s.right(slash + 1);
  58. >     }
  59. > #ifdef VMS        // H. Dahms  13.11.92
  60. >     int dot = s.index('.');
  61. >     if (dot >= 0) {
  62. >         s = s.substr(0, dot);
  63. >     }
  64. > #endif
  65. >     return new String(s);
  66. >     }
  67. >     return new String("noname");
  68. > }
  69.  
  70. I got a mail from Carlos Vidal (atocavi@ato.abb.se) who suggests using another
  71. buffer and strncpy. Instead, I took another look at session.c and found there
  72.  
  73. const char* Session::name() const { return rep_->name_->string(); }
  74.  
  75. which ignores the length field of the string class! That's the real bug!
  76. The fix is just easy (again in session.c):
  77.  
  78. #ifdef VMS              // H. Dahms  16.11.92
  79.         int dot = s.index('.');
  80.         if (dot >= 0) {
  81.             s = s.substr(0, dot);
  82.         }
  83.         return new CopyString(s);
  84. #else
  85.         return new String(s);
  86. #endif
  87.  
  88. Nevertheless, thanks to Carlos,
  89. Heribert
  90.