Re: XForms: strcmp

From: Ivan Powis (Ivan.Powis@nottingham.ac.uk)
Date: Thu Nov 23 2000 - 11:32:37 EST

  • Next message: Steve Lamont: "Re: XForms: spreadsheet??"

    # To subscribers of the xforms list from Ivan Powis <Ivan.Powis@nottingham.ac.uk> :

    >
    > # To subscribers of the xforms list from joel <joel@dabbles-n-doodads.com> :
    >
    > Actually, I'm looking for an empty string not if a pointer is null. So,
    > strcmp(string,"") works fine. I'm not sure why NULL works under
    > HPUX. I checked how its defined, and NULL = 0 under both OS's.
    > So maybe either the compiler or the implementation of strcmp under
    > HPUX views NULL as an empty string? Anyhow, as someone else
    > emailed me strcmp(string,"") is really what I meant to do and works
    > fine under both OS's.
    >

    HPUX by default dereferences NULL pointers as you have seen exactly so
    that their use does not generate error traps. Thus your use of a NULL
    pointer to mean "" works fine on HP although it was surely wrong to
    write your particular example this way. This feature is sometimes
    "useful" for the non-rigorous programmer eg with a file selector which
    may return a null string if cancelled. A strcmp or similar can then
    check the returned string without needing to explicitly check for a
    null pointer return. I discovered this when porting some xforms apps
    from HP to Linux.

    Ivan

    --
    --------------------------------------------------------------------
        ___  ___/   _  __ /   Ivan Powis   [Ivan.Powis@Nottingham.ac.uk]
            /         /   /   School of Chemistry
           /         /  _/    University of Nottingham
          /         ___/      Nottingham NG7 2RD, UK
         /         /     TEL: +44-115-951-3467
        /         /      FAX: +44-115-951-3562
    _______/  ____/      http://www.chem.nott.ac.uk/IP.html
    --------------------------------------------------------------------
    

    _________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuhs.mil or see http://bob.usuhs.mil/mailserv/xforms.html XForms Home Page: http://world.std.com/~xforms List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Thu Nov 23 2000 - 11:35:33 EST