Article View: comp.windows.interviews
Article #1269Re: Problem with iv3.1-beta3 string class (lacks documentation!)
From: Heribert Dahms
Date: Mon, 16 Nov 1992 14:38
Date: Mon, 16 Nov 1992 14:38
87 lines
3265 bytes
3265 bytes
In <1992Nov13.160516.19376@rz.uni-karlsruhe.de> DAHMS@ifk20.mach.uni-karlsruhe.de writes:
> I'm just porting iv3.1-beta3 to VAX/VMS and got a little problem with the
> string class of InterViews in session.c .
>
> I miss a complete description of the string class in A.6 of the iv-Manual
> and also in the man pages (which i converted to a VMS help library).
>
> I try cutting the argv[0] string (program name) from e.g.
> ifkvs2$dkb0:[interviews31]idemo.exe;7
> first to
> idemo.exe;7
> which works, but then i want to get
> idemo
> i.e. the part of the string to the left of the dot (if any), but several
> attempts resulted in keeping
> idemo.exe;7
>
> That's obviously no problem with VMS itself, only with the string handling!
> What's wrong?
>
>
> Thanks,
> Heribert Dahms (dahms@ifk20.mach.uni-karlsruhe.de)
>
> =============================================================================
> Extract of src/lib/interviews/session.c :
> =============================================================================
>
> /*
> * Use ICCCM rules to find an application's instance name
> * from the command line or an environment variable.
> */
>
> String* SessionRep::find_name() {
> String name;
> if (find_arg(String("-name"), name)) {
> return new String(name);
> }
>
> const char* res_name = getenv("RESOURCE_NAME");
> if (res_name != nil) {
> return new String(res_name);
> }
>
> if (argc_ > 0) {
> String s(argv_[0]);
> #ifdef VMS // H. Dahms 12.11.92
> int slash = s.rindex(']');
> #else
> int slash = s.rindex('/');
> #endif
> if (slash >= 0) {
> s = s.right(slash + 1);
> }
> #ifdef VMS // H. Dahms 13.11.92
> int dot = s.index('.');
> if (dot >= 0) {
> s = s.substr(0, dot);
> }
> #endif
> return new String(s);
> }
>
> return new String("noname");
> }
I got a mail from Carlos Vidal (atocavi@ato.abb.se) who suggests using another
buffer and strncpy. Instead, I took another look at session.c and found there
const char* Session::name() const { return rep_->name_->string(); }
which ignores the length field of the string class! That's the real bug!
The fix is just easy (again in session.c):
#ifdef VMS // H. Dahms 16.11.92
int dot = s.index('.');
if (dot >= 0) {
s = s.substr(0, dot);
}
return new CopyString(s);
#else
return new String(s);
#endif
Nevertheless, thanks to Carlos,
Heribert
Technical Details
Message-ID:
<1992Nov16.143842.22052@rz.uni-karlsruhe.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!ira.uka.de!rz.uni-karlsruhe.de!usenetReferences:
<1992Nov13.160516.19376@rz.uni-karlsruhe.de>Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.interviews Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!emory!sol.ctr.columbia.edu!ira.uka.de!rz.uni-karlsruhe.de!usenet From: DAHMS@ifk20.mach.uni-karlsruhe.de (Heribert Dahms) Subject: Re: Problem with iv3.1-beta3 string class (lacks documentation!) In-Reply-To: DAHMS@ifk20.mach.uni-karlsruhe.de's message of Fri, 13 Nov 1992 16: 05:16 GMT Message-ID: <1992Nov16.143842.22052@rz.uni-karlsruhe.de> Sender: usenet@rz.uni-karlsruhe.de (USENET 'No news is bad news' News System) Organization: University of Karlsruhe, FRG (Dept. of Mechanical Engineering) References: <1992Nov13.160516.19376@rz.uni-karlsruhe.de> Date: Mon, 16 Nov 1992 14:38:42 GMT X-News-Reader: VMS NEWS 1.20 Lines: 87