Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README package mgr info #44

Merged
merged 2 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions app/2tsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ unsigned char *zsv_to_tsv(const unsigned char *utf8, size_t *len, enum zsv_2tsv_
// replace tab, newline and lf with \t, \n or \r or backslash
size_t do_convert = 0;
for(size_t i = 0; i < *len; i++) {
if(VERY_UNLIKELY(utf8[i] == '\t') || VERY_UNLIKELY(utf8[i] == '\n') || VERY_UNLIKELY(utf8[i] == '\r') || VERY_UNLIKELY(utf8[i] == '\\'))
if(UNLIKELY(utf8[i] == '\t' || utf8[i] == '\n' || utf8[i] == '\r' || utf8[i] == '\\'))
do_convert++;
}

if(LIKELY(do_convert == 0))
return NULL;

Expand All @@ -90,20 +89,23 @@ unsigned char *zsv_to_tsv(const unsigned char *utf8, size_t *len, enum zsv_2tsv_
}

__attribute__((always_inline)) static inline
void zsv_2tsv_cell(struct zsv_2tsv_data *data, unsigned char *utf8_value, size_t len, char no_escape) {
void zsv_2tsv_cell(struct zsv_2tsv_data *data, unsigned char *utf8_value, size_t len,
char no_newline_or_slash) {
// output cell contents (converted if necessary)
if(len) {
enum zsv_2tsv_status err = zsv_2tsv_status_ok;
if(LIKELY(no_escape)) {
if(VERY_LIKELY(no_newline_or_slash && !memchr(utf8_value, '\t', len))) {
zsv_2tsv_write(&data->out, utf8_value, len);
return;
}

// if we're here, there either definitely an embedded tab, or maybe an embedded \n or \r
unsigned char *converted = zsv_to_tsv(utf8_value, &len, &err);
if(UNLIKELY(converted != NULL)) {
if(converted != NULL) {
zsv_2tsv_write(&data->out, converted, len);
free(converted);
} else if(VERY_UNLIKELY(err != zsv_2tsv_status_ok))
; // handle out-of-memory error!
} else if(UNLIKELY(err))
fprintf(stderr, "Out of memory!\n");
else
zsv_2tsv_write(&data->out, utf8_value, len);
}
Expand All @@ -126,20 +128,22 @@ static void zsv_2tsv_row(void *ctx) {
unsigned int cols = zsv_column_count(data->parser);
if(cols) {
struct zsv_cell cell = zsv_get_cell(data->parser, 0);
char no_escape = 0;
if(cols > 1) {
struct zsv_cell end = zsv_get_cell(data->parser, cols-1);
unsigned char *start = cell.str;
size_t row_len = end.str + end.len - start;
if(!(memchr(start, '\t', row_len) || memchr(start, '\n', row_len) || memchr(start, '\r', row_len) || memchr(start, '\\', row_len)))
no_escape = 1;
}
zsv_2tsv_cell(ctx, cell.str, cell.len, no_escape);

struct zsv_cell end = zsv_get_cell(data->parser, cols-1);
unsigned char *start = cell.str;
size_t row_len = end.str + end.len - start;
char no_newline_or_slash = 0;
if(LIKELY(!(
memchr(start, '\n', row_len) ||
memchr(start, '\r', row_len) ||
memchr(start, '\\', row_len)
)))
no_newline_or_slash = 1;

zsv_2tsv_cell(ctx, cell.str, cell.len, no_newline_or_slash);
for(unsigned int i = 1; i < cols; i++) {
zsv_2tsv_write(&data->out, (const unsigned char *)"\t", 1);
cell = zsv_get_cell(data->parser, i);
zsv_2tsv_cell(ctx, cell.str, cell.len, no_escape);
zsv_2tsv_cell(ctx, cell.str, cell.len, no_newline_or_slash);
}
}
zsv_2tsv_write(&data->out, (const unsigned char *) "\n", 1);
Expand Down
55 changes: 55 additions & 0 deletions app/benchmark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,97 @@ count: worldcitiespop_mil.csv worldcitiespop_mil.tsv

@printf "zsv : "
@(time ${ZSVBIN}count < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}count < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}count < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "xsv : "
@(time xsv count < $< > /dev/null) 2>&1 | xargs
@printf "xsv : "
@(time xsv count < $< > /dev/null) 2>&1 | xargs
@printf "xsv : "
@(time xsv count < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines -d, < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines -d, < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines -d, < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines < $(word 2,$^) > /dev/null) 2>&1 | xargs
@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines < $(word 2,$^) > /dev/null) 2>&1 | xargs
@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/number-lines < $(word 2,$^) > /dev/null) 2>&1 | xargs
@echo ""

tsv: worldcitiespop_mil.csv
@echo "${ZSVBIN}"2tsv

@printf "zsv : "
@(time ${ZSVBIN}2tsv < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}2tsv < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}2tsv < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "tsv-utils (csv2tsv) : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/csv2tsv < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils (csv2tsv) : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/csv2tsv < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils (csv2tsv) : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/csv2tsv < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "c-blake/nio/c2tsv : " # from https://github.com/c-blake/nio
@(time c2tsv < $< > /dev/null) 2>&1 | xargs
@printf "c-blake/nio/c2tsv : "
@(time c2tsv < $< > /dev/null) 2>&1 | xargs
@printf "c-blake/nio/c2tsv : "
@(time c2tsv < $< > /dev/null) 2>&1 | xargs
@echo ""


select: worldcitiespop_mil.csv worldcitiespop_mil.tsv
@echo "${ZSVBIN}"select
@printf "zsv : "
@(time ${ZSVBIN}select -W -n -- 2 1 3-7 < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}select -W -n -- 2 1 3-7 < $< > /dev/null) 2>&1 | xargs
@printf "zsv : "
@(time ${ZSVBIN}select -W -n -- 2 1 3-7 < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "xsv : "
@(time xsv select 2,1,3-7 < $< > /dev/null) 2>&1 | xargs
@printf "xsv : "
@(time xsv select 2,1,3-7 < $< > /dev/null) 2>&1 | xargs
@printf "xsv : "
@(time xsv select 2,1,3-7 < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -d, -f 1-7 < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -d, -f 1-7 < $< > /dev/null) 2>&1 | xargs
@printf "tsv-utils : "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -d, -f 1-7 < $< > /dev/null) 2>&1 | xargs
@echo ""

@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -f 1-7 < $(word 2,$^) > /dev/null) 2>&1 | xargs
@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -f 1-7 < $(word 2,$^) > /dev/null) 2>&1 | xargs
@printf "tsv-utils (tsv input): "
@(time ~/Downloads/tsv-utils-v2.2.1_osx-x86_64_ldc2/bin/tsv-select -f 1-7 < $(word 2,$^) > /dev/null) 2>&1 | xargs
@echo ""

ifneq ($(QUICK),1)
@printf "csvcut : "
Expand Down
2 changes: 1 addition & 1 deletion app/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SOURCES=
ifneq ($(CLI1),1)
SOURCES+=echo
endif
SOURCES+= select sql 2json serialize flatten pretty desc stack 2db jq
SOURCES+= count select sql 2json serialize flatten pretty desc stack 2db jq 2tsv
TARGETS=$(addprefix ${BUILD_DIR}/bin/zsv_,$(addsuffix ${EXE},${SOURCES}))

TESTS=$(addprefix test-,${SOURCES})
Expand Down
6 changes: 3 additions & 3 deletions app/test/expected/test-2tsv.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
useful data --> useful data --> Primary Servicer ServicingFee % ServicingFee? Flatdollar ServicingAdvance Methodology Originator Loan Group Loan Number Amortization Type Lien Position HELOC Indicator Loan Purpose Cash Out Amount Total Origination and Discount Points Covered/High Cost Loan Indicator Relocation Loan Indicator Broker Indicator Channel Escrow Indicator Senior Loan Amount(s) Loan Type of Most Senior Lien Hybrid PeriodofMost Senior Lien (inmonths) Neg Am Limit ofMost Senior Lien Junior MortgageBalance Origination Date ofMost Senior Lien Origination Date Original LoanAmount Original InterestRate OriginalAmortization Term Original Term toMaturity First Payment Dateof Loan Interest Type Indicator Original Interest Only Term Buy Down Period HELOC Draw Period Current Loan Amount Current Interest Rate Current Payment Amount Due Interest Paid Through Date Current Payment Status Index Type ARM Look-backDays Gross Margin ARM Round Flag ARM Round Factor Initial Fixed RatePeriod Initial Interest RateCap (Change Up) Initial Interest RateCap (Change Down) Subsequent InterestRate Reset Period Subsequent InterestRate Cap (Change Down) Subsequent InterestRate Cap (ChangeUp) Lifetime MaximumRate (Ceiling) Lifetime MinimumRate (Floor) NegativeAmortization Limit Initial NegativeAmortization RecastPeriod SubsequentNegativeAmortization RecastPeriod Initial FixedPayment Period SubsequentPayment ResetPeriod Initial PeriodicPayment Cap SubsequentPeriodic PaymentCap Initial MinimumPayment ResetPeriod SubsequentMinimum PaymentReset Period Option ARMIndicator Options at Recast Initial MinimumPayment Current MinimumPayment Prepayment PenaltyCalculation Prepayment PenaltyType Prepayment PenaltyTotal Term Prepayment PenaltyHard Term Primary Borrower ID Number ofMortgagedProperties Total Number ofBorrowers Self-employmentFlag Current ?Other?Monthly Payment Length ofEmployment:Borrower Length ofEmployment: Co-Borrower Years in Home FICO Model Used Most Recent FICODate Primary WageEarner OriginalFICO: Equifax Primary WageEarner OriginalFICO: Experian Primary WageEarner OriginalFICO: TransUnion Secondary WageEarner OriginalFICO: Equifax Secondary WageEarner OriginalFICO: Experian Secondary WageEarner OriginalFICO: TransUnion OriginalPrimary BorrowerFICO Most RecentPrimary BorrowerFICO Most Recent Co-Borrower FICO Most Recent FICOMethod VantageScore:Primary Borrower VantageScore: Co-Borrower Most RecentVantageScoreMethod VantageScore Date Credit Report:Longest Trade Line Credit Report:Maximum TradeLine Credit Report:Number of TradeLines Credit Line UsageRatio Most Recent 12-month Pay History Months Bankruptcy Months Foreclosure Primary BorrowerWage Income Co-Borrower WageIncome Primary BorrowerOther Income Co-Borrower OtherIncome All Borrower WageIncome All Borrower TotalIncome 4506-T Indicator Borrower IncomeVerification Level Co-BorrowerIncome Verification BorrowerEmploymentVerification Co-BorrowerEmploymentVerification Borrower AssetVerification Co-Borrower AssetVerification Liquid / CashReserves Monthly Debt AllBorrowers Originator DTI Fully Indexed Rate QualificationMethod Percentage of DownPayment fromBorrower OwnFunds City State Postal Code Property Type Occupancy Sales Price Original AppraisedProperty Value Original PropertyValuation Type Original PropertyValuation Date OriginalAutomated Valuation Model (AVM) Model Name OriginalAVM Confidence Score MostRecent Property Value2 MostRecent Property Valuation Type MostRecent Property Valuation Date MostRecent AVM ModelName MostRecent AVM Confidence Score OriginalCLTV OriginalLTV OriginalPledged Assets MortgageInsurance CompanyName Mortgage Insurance Percent MI: Lender orBorrower Paid? Pool Insurance Co.Name Pool Insurance StopLoss % MI CertificateNumber Updated DTI(Front-end) Updated DTI(Back-end) ModificationEffective PaymentDate Total CapitalizedAmount Total DeferredAmount Pre- ModificationInterest (Note) Rate Pre- Modification P&IPayment Pre- ModificationInitial Interest RateChange DownwardCap Pre- ModificationSubsequent InterestRate Cap Pre- ModificationNext Interest RateChange Date Pre- Modification I/OTerm Forgiven PrincipalAmount Forgiven InterestAmount Number ofModifications Cash To/From Brrw at Closing Brrw - Yrs at in Industry CoBrrw - Yrs at in Industry Junior Mortgage Drawn Amount Maturity Date PrimaryBorrower Wage Income (Salary) PrimaryBorrower Wage Income (Bonus) PrimaryBorrower Wage Income (Commission) Co-Borrower Wage Income (Salary) Co-Borrower Wage Income (Bonus) Co-Borrower Wage Income (Commission) Originator Doc Code Income Verification Asset Verification
embedded\nnewline 1002338 0.0025 1002338 Group 1 978000019 2 1 0 9 1 0 0 0 20111025 1000000 0.042 360 360 20111201 1 120 0 1,000,000.00 0.042 3500 20130101 0 35 45 0.01625 3 0.00125 120 0.05 0.05 1 0 0 0.092 0.029 99 99 60 58 1 1 14 0 7 1 20121212 801 789 3 0 6193 0 5155 0 6193 11348 0 5 2 3 966841.81 4530.12 0.3992 Vancouver WA 98661 2 1 1740000 3 20110914 0.5747 0.5747 0 0 0 14 0 0 20411101 6193 0 0 0 0 Full Two Years One Month
useful data --> 1002338 0.0025 1002338 Group 1 978000078 2 1 0 7 1 0 0 280000 20110707 1000000 0.0415 360 360 20110901 1 120 0 1,000,000.00 0.0415 3458.33 20130101 0 35 45 0.01625 3 0.00125 120 0.05 0.05 1 0 0 0.0915 0.029 99 99 60 455 3 0 15 3 0 1 20121212 788 788 3 0 8333.33 7002 10870.56 0 15335.33 26205.97 0 5 2 4 4942401.6 7337.67 0.28 100 KELSO WA 98626 1 1 1600000 1700000 3 20110602 0.8 0.625 0 0 0 15 4 280000 20410801 8333 0 0 7002 0 0 Full Two Years Two Months
1000383 0.0025 9999999 Group 1 1000001102 2 1 0 9 1 0 0 57500 20111024 502500 0.04625 360 360 20111201 1 0 0 493,213.96 0.04625 2583.55 20130101 0 39 45 0.0275 3 0.00125 120 0.05 0.05 12 0.02 0.02 0.09625 0.0275 0 364 1 1 0.5 3.8 4 1 20121212 762 743 3 0 6229.17 7355.79 0 0 13584.96 13584.96 1 5 3 4 67201.4 5879.57 0.4328 Olympia WA 98502 7 1 670000 3 20110906 0.8358 0.75 0 0 0 12 3.8 57500 20411101 6229.17 0 0 7355.79 0 0 Full Two Years Two Months
embedded\nnewline 1002338 0.0025 1002338 Group 1 978000019 2 1 0 9 1 0 0 0 20111025 1000000 0.042 360 360 20111201 1 120 0 1,000,000.00 0.042 3500 20130101 0 35 45 0.01625 3 0.00125 120 0.05 0.05 1 0 0 0.092 0.029 99 99 60 58 1 1 14 0 7 1 20121212 801 789 3 0 6193 0 embedded\ttab5155 0 6193 11348 0 5 2 3 966841.81 4530.12 0.3992 Vancouver WA 98661 2 1 1740000 3 20110914 0.5747 0.5747 0 0 0 14 0 0 20411101 6193 0 0 0 0 Full Two Years One Month
useful data --> 1002338 0.0025 1002338 Group 1 978000078 2 1 0 7 1 0 0 280000 embedded\ttab20110707 1000000 0.0415 360 360 20110901 1 120 0 1,000,000.00 0.0415 3458.33 20130101 0 35 45 0.01625 3 0.00125 120 0.05 0.05 1 0 0 0.0915 0.029 99 99 60 455 3 0 15 3 0 1 20121212 788 788 3 0 8333.33 7002 10870.56 0 15335.33 26205.97 0 5 2 4 4942401.6 7337.67 0.28 100 KELSO WA 98626 1 1 1600000 1700000 3 20110602 0.8 0.625 0 0 0 15 4 280000 20410801 8333 0 0 7002 0 0 Full Two Years Two Months
1000383 0.0025 9999999 Group 1 1000001102 2 1 0 9 1 0 0 57500 20111024 502500 0.04625 360 360 embedded\\backslash20111201 1 0 0 493,213.96 0.04625 2583.55 20130101 0 39 45 0.0275 3 0.00125 120 0.05 0.05 12 0.02 0.02 0.09625 0.0275 0 364 1 1 0.5 3.8 4 1 20121212 762 743 3 0 6229.17 7355.79 0 0 13584.96 13584.96 1 5 3 4 67201.4 5879.57 0.4328 Olympia WA 98502 7 1 670000 3 20110906 0.8358 0.75 0 0 0 12 3.8 57500 20411101 6229.17 0 0 7355.79 0 0 Full Two Years Two Months
1000383 0.0025 9999999 Group 1 1010007709 1 1 0 9 1 0 0 250000 20121023 715000 0.035 180 180 20121201 1 0 0 708,939.19 0.035 5111.41 20130101 0 0 420 2 0 11 2 1 772 0 25781.25 0 0 0 25781.25 25781.25 1 5 3 4 196542.45 8405.41 0.326028 GIG HARBOR WA 98332 1 1 2100000 3 20121003 0.4595 0.3404 0 0 0 12 130389 20271101 25781.25 0 0 0 0 0 Full Two Years Two Months
1000383 0.0025 9999999 Group 1 1030004301 1 1 0 9 2 0 0 0 20120911 694000 0.035 180 180 20121101 1 0 0 685,162.93 0.035 4961.28 20130101 0 0 202 1 1 8.5 9 1 767 0 24723 0 0 0 24723 24723 1 5 3 4 652220.12 8687.54 0.351395 MARYSVILLE WA 98271 1 1 900000 3 20120419 0.7711 0.7711 0 0 0 25 0 20271001 24723 0 0 0 0 0 Full Two Years Two Months
1000383 0.0025 9999999 Group 1 1030006057 1 1 0 9 1 0 0 0 20120830 770000 0.035 180 180 20121101 1 0 0 760,195.16 0.035 5504.6 20130101 0 0 404 3 1 33 33 4 1 797 0 269436.19 269436.19 0 0 538872.38 538872.38 1 5 3 4 861493.44 50769.32 0.094214 Seattle WA 98144 7 1 1100000 3 20120710 0.7 0.7 0 0 0 33 33 0 20271001 269436.19 0 0 269436.19 0 0 Full Two Years Two Months
Expand Down
53 changes: 30 additions & 23 deletions app/utils/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static unsigned char *utf8proc_tolower_str(const unsigned char *str, size_t *len

// utf8proc_map_custom allocates new mem
options = UTF8PROC_STRIPNA;
*len = (size_t) utf8proc_map_custom((const utf8proc_uint8_t *)str, *len, &output,
*len = (size_t) utf8proc_map_custom((const utf8proc_uint8_t *)str, (utf8proc_ssize_t)*len, &output,
options, utf8proc_tolower1, NULL);
return (unsigned char *)output;
}
Expand Down Expand Up @@ -73,38 +73,45 @@ const unsigned char *zsv_strstr(const unsigned char *hay, const unsigned char *n
(const char *)needle);
}

// zsv_stricmp(). to do: utf8 support
/*
* zsv_stricmp, zsv_strincmp(): case-insensitive comparison
*
* @param s1 string to convert
* @param len1 length of s1
* @param s2 string to convert
* @param len2 length of s2
*/
int zsv_stricmp(const unsigned char *s1, const unsigned char *s2) {
while(1) {
char c1 = tolower(*s1);
char c2 = tolower(*s2);
if(c1 == c2) {
if(!c1)
return 0;
s1++, s2++;
} else
return c1 < c2 ? -1 : 1;
}
return zsv_strincmp(s1, strlen((const char *)s1), s2, strlen((const char *)s2));
}

// zsv_strincmp(). to do: utf8 support
int zsv_strincmp(const unsigned char *s1, size_t len1, const unsigned char *s2, size_t len2) {
// this is just a placeholder for demonstration purposes
// this function will NOT work properly on multi-byte utf8 chars, but will work fine on ascii
if(len1 != len2)
return len1 < len2 ? -1 : 1;

#ifndef NO_UTF8PROC
unsigned char *lc1 = zsv_strtolowercase(s1, &len1);
unsigned char *lc2 = zsv_strtolowercase(s2, &len2);
int result;
if(VERY_UNLIKELY(!lc1 || !lc2))
fprintf(stderr, "Out of memory!\n"), result = -2;
else
result = strcmp((char *)lc1, (char *)lc2);
free(lc1);
free(lc2);
return result;
#else
while(len1) {
char c1 = tolower(*s1);
char c2 = tolower(*s2);
if(!*s1)
return *s2 == 0 ? 0 : -1;
if(!*s2)
return 1;
int c1 = tolower(*s1);
int c2 = tolower(*s2);
if(c1 == c2) {
if(!c1)
return 0;
s1++, s2++, len1--;
} else
return c1 < c2 ? -1 : 1;
}
return 0;
#endif
}

// zsv_trim(): trim leading and trailing white space. to do: utf8 support
Expand Down Expand Up @@ -171,7 +178,7 @@ size_t zsv_strwhite(unsigned char *s, size_t len, unsigned int flags) {
#endif // ndef NO_UTF8PROC

if(this_is_space) {
if(UNLIKELY(s[i] == '\n' || s[i] == '\r') && !(flags & ZSV_STRWHITE_FLAG_NO_EMBEDDED_NEWLINE))
if(UNLIKELY((s[i] == '\n' || s[i] == '\r')) && !(flags & ZSV_STRWHITE_FLAG_NO_EMBEDDED_NEWLINE))
replacement = '\n';
else if(!last_was_space)
replacement = ' ';
Expand Down
Loading