Talk:Trimming (computer programming)
![]() | This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||
|
C/C++ example needs actual code
editThe C/C++ example isn't too illustrative of the theory behind trimming a string in C. Perhaps an example that contains the actual code would be more appropriate. (I want to see some loops in there!) --indil 20:55, 19 July 2006 (UTC)
- I went for a brief overview and stuck with the simplest functions/libraries/implementations I could find. Please feel free to add some code :) —Pengo talk · contribs 13:02, 23 July 2006 (UTC)
- I've changed the code for the C example. I believe the old example would have leaked memory - for processing large amounts of data, this could cause problems! On a side note, could someone check to make sure I haven't done something dumb while writing this (it compiled and worked in VC++) --Portej 07:29, 26 September 2007 (UTC)
- At least for me the example in C does NOT work. i doubled checked it, but still believe, that i did not make a mistake. the problematic section is shown below. this causes a segmentation fault in my environment (gcc-4.1.3). --Alex.blackbit 18:32, 1 November 2007 (UTC)
if (last != input)
last[1] = 0;
- Alex, this is with strings that don't need trimming? Yeh, last should have been initialized with ret before the loop. I'm fine with just dropping the code though, if it wasn't just a line count thing. James Antill 16:03, 6 November 2007 (UTC)
in AWK better to use those command:
function ltrim(s) { sub(/^ */, "", s); return s }
function rtrim(s) { sub(/ *$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
Keep the functions. Remove just code
editHi, I think you should remove the "other languages which don't have trim functions" section. They don't have trim or a close analogue, so they should be trimmed. It is superfluous text at the end of the article that happens to take up more than half the article that is supposed to be on trim rather than what is not trim. It is quite easy to define trim-like and, by omision what is not trim-like. That section becomes a tutorial on how to write trim in other languages and should be removed or moved to this talk page. Please refer to this. --Paddy 05:32, 10 October 2007 (UTC)
- It's about trim library functions as well as trim algorithms. Most of the examples (except C) are only one or two lines of code (which is probably why they don't have library functions). Hardly a hand-holding instruction manual. Leaving them out is to pretend trimming isn't used in these languages, and removes much of the language-specific discussion. Lastly, the code certainly doesn't belong on the talk page. —Pengo 14:26, 10 October 2007 (UTC)
- I see what you mean about the short examples, and also not transferring them to the talk pages, but that large chunk of C? Surely that should go. --Paddy 15:32, 10 October 2007 (UTC)
- Yep, probably. Would be nice to move it to Wikibooks, or at least include a link to an open source implementation of the same thing though. —Pengo 06:09, 11 October 2007 (UTC)
- The only point is that if that trim function was used on a large dataset, with lots of whitespace, it would leak memory at a heck of a rate. Is there anywhere that implementations can go? (someone mentioned wikibooks) —Preceding unsigned comment added by 203.59.18.181 (talk) 14:37, 17 October 2007 (UTC)
- I dropped the line count significantly on the C example, and it now doesn't allocate memory. Both of which make it much more likely to resemble a real implementation IMO. --James Antill 05:32, 19 October 2007 (UTC)
- Thanks, it is more succinct, but the point remains that the C function is showing how to write trim in C which does not have trim. Best to leave it out and rely on the mention of external libraries that give trim functionality as a package. --Paddy 18:04, 19 October 2007 (UTC)
- I've re-removed the C function, as it seems to be a perennial problem. The other code in the article is well established and used frequently in copy/paste programming. I don't think Wikipedia is the best environment to write new code. It could even be seen as "original research". —Pengo 01:08, 2 November 2007 (UTC)
SAS has a trimmed TRIM
editthe SAS language has a STRIP function, but this only removes the space (ASCII 0x20) characters, not all whitespace. —Preceding unsigned comment added by 165.155.110.5 (talk) 14:32, 8 February 2011 (UTC)
External links modified
editHello fellow Wikipedians,
I have just added archive links to one external link on Trimming (computer programming). Please take a moment to review my edit. If necessary, add {{cbignore}}
after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}}
to keep me off the page altogether. I made the following changes:
- Added archive https://web.archive.org/20090802041055/http://doc.trolltech.com:80/4.5/qstring.html to http://doc.trolltech.com/4.5/qstring.html#trimmed
When you have finished reviewing my changes, please set the checked parameter below to true to let others know.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
- If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
- If you found an error with any archives or the URLs themselves, you can fix them with this tool.
Cheers.—cyberbot IITalk to my owner:Online 07:23, 15 January 2016 (UTC)