Changeset 227 for trunk/foundation/class_c
- Timestamp:
- Feb 4, 2007, 10:51:43 PM (19 years ago)
- Location:
- trunk/foundation/class_c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/foundation/class_c/nomfilepath.c
r225 r227 16 16 * The Initial Developer of the Original Code is 17 17 * netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>. 18 * Portions created by the Initial Developer are Copyright (C) 2006 18 * Portions created by the Initial Developer are Copyright (C) 2006-2007 19 19 * the Initial Developer. All Rights Reserved. 20 20 * … … 55 55 added to the path prior to appending. If the given string starts with a separator and the current 56 56 path ends with a separator the ending separator will be removed before appending. 57 If no input path is given only a separator is appended if necessary. 57 58 58 59 Note that there's no check if the input string is an absolute path. So if an absolute path is given as … … 72 73 return NOMPath_appendSeparator(nomSelf, ev); 73 74 75 /* This is not a copy */ 74 76 chrTemp=NOMPath_queryCString(nomPath, NULLHANDLE); 75 77 if(G_DIR_SEPARATOR==chrTemp[0]) 76 78 np=NOMPath_stripSeparator(nomSelf, ev); 77 else {79 else 78 80 np=NOMPath_appendSeparator(nomSelf, ev); /* Make sure current path has a separator */ 79 }80 81 81 82 return (NOMPath*) NOMPath_append((NOMString*) np, (NOMString*)nomPath, NULLHANDLE); … … 84 85 /** 85 86 Append a separator to the path. If the path already has a separator at the end this method does 86 nothing other than returning a new path object. If the given path has zero length apath object87 nothing other than returning the path object. If the given path has zero length the path object 87 88 only holding a separator is returned. 88 89 … … 94 95 gulong len; 95 96 97 /* Return only a separator */ 96 98 if((len=NOMPath_length((NOMString*)nomSelf, ev))==0) 97 99 return (NOMPath*)NOMPath_appendCString((NOMString*)nomSelf, G_DIR_SEPARATOR_S, ev); 98 100 101 /* Add a separator */ 99 102 if(G_DIR_SEPARATOR!=chrTemp[len-1]) 100 103 return (NOMPath*)NOMPath_appendCString( (NOMString*)nomSelf, G_DIR_SEPARATOR_S, ev); 101 104 102 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE);105 return nomSelf; 103 106 } 104 107 … … 106 109 Strips the path separator from the end of a path if there's one. 107 110 108 This method always returns a new instance of a NOMPath owned by the caller.111 This method returns the same instance of a NOMPath. 109 112 */ 110 113 NOM_Scope PNOMPath NOMLINK impl_NOMPath_stripSeparator(NOMPath* nomSelf, CORBA_Environment *ev) … … 114 117 115 118 if((len=NOMPath_length((NOMString*)nomSelf, NULLHANDLE))==0) 116 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE); 117 119 return nomSelf; 120 121 /* This is not a copy */ 118 122 chrTemp=NOMPath_queryCString((NOMString*)nomSelf, NULLHANDLE); 119 123 … … 121 125 return (NOMPath*)NOMPath_truncate( (NOMString*)nomSelf, len-1, NULLHANDLE); 122 126 123 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE);127 return nomSelf; 124 128 } 125 129 -
trunk/foundation/class_c/nomstring.c
r209 r227 90 90 { 91 91 NOMStringData* nomThis=NOMStringGetData(nomSelf); 92 PNOMString nomRetval=(PNOMString) NOMString_new(nomSelf, NULLHANDLE);93 GString* gStrTmp;94 92 95 gStrTmp=g_string_new(_gString->str); 96 g_string_append(gStrTmp, chrString); 97 NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE); 98 g_string_free(gStrTmp, TRUE); 93 g_string_append(_gString, chrString); 99 94 100 return nom Retval;95 return nomSelf; 101 96 } 102 97 … … 104 99 CORBA_Environment *ev) 105 100 { 106 /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */107 108 101 return NOMString_appendCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE); 109 102 } … … 112 105 CORBA_Environment *ev) 113 106 { 114 /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */115 116 107 return NOMString_prependCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE); 117 108 } … … 120 111 { 121 112 NOMStringData* nomThis=NOMStringGetData(nomSelf); 122 PNOMString nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE); 123 GString* gStrTmp; 113 g_string_prepend(_gString, chrString); 124 114 125 gStrTmp=g_string_new(_gString->str); 126 g_string_prepend(gStrTmp, chrString); 127 NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE); 128 g_string_free(gStrTmp, TRUE); 129 130 return nomRetval; 115 return nomSelf; 131 116 } 132 117 … … 142 127 { 143 128 NOMStringData* nomThis=NOMStringGetData(nomSelf); 144 PNOMString nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE);145 GString* gStrTmp;146 129 147 gStrTmp=g_string_new(_gString->str); 148 g_string_truncate(gStrTmp, ulNewLen); 149 NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE); 150 g_string_free(gStrTmp, TRUE); 130 g_string_truncate(_gString, ulNewLen); 151 131 152 return nom Retval;132 return nomSelf; 153 133 } 154 134
Note:
See TracChangeset
for help on using the changeset viewer.