Utility: match
Mike Acton
April 07, 2007
April 07, 2007
Update! If fixed up all the greater-than and less-than symbols in this entry. I didn't make much sense before. I always forget to change those up in the HTML.
I'm just sharing a little utility I use all the time called match. Usage: ./match [-h] <source_file> <uniq_file> For each line in <source_file> print the index to the first matching line in <uniq_file>. [-h] Print results in 32 bit hexidecimal (default is decimal) Note: The max line width supported is 4095 characters. Note: Maximum number of lines supported is (2^32)If I have a source file of data represented as text (as I often do because it's often easier for me to read binary dumps in a text editor than a special "hex editor"), I use match to create a table of indices to unique lines (often these correspond to 128 bits since that's the size of an SPU register).
I commonly use it like so (given I have a file called "source_file")
sort source_file | uniq > uniq_file match source_file uniq_fileNow I have a handy table of indices!
Download: match.c
ABOUT THE AUTHOR
Mike Acton is the director and adminstrator of CellPerformance,
is dedicated to helping the Cell community as much as possible
and plies his trade developing technology for PS3 games. Mike has made regular appearances as a speaker at SCEA develpment conferences and other events. Mike Acton is not a framework-happy C++ programmer. He actually likes C. And assembly. In his spare time he develops hardware on FPGAs in VHDL.
He prefers vi.
Also check out the CellPerformance main site, which has additional articles written by Mike Acton.