Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WString - assume c-string is a pointer to flash in all cases#9272

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mcspr wants to merge19 commits intoesp8266:master
base:master
Choose a base branch
Loading
frommcspr:string/cstr-pgmspace-funcs

Conversation

@mcspr
Copy link
Collaborator

@mcsprmcspr commentedAug 29, 2025
edited
Loading

Currently, it is mixed. Some methods allow it, some fall back to newlib or ROM funcs. Some converted c-string to String(). Or, some caused implicit conversion nuance (like String(const char*) and operator=(const char*))

Instead, try to pass data through as c-string + its length and minimize String() conversions. This also drops most of the__FlashStringHelper overloads in favour of forcibly casting it to c-string.
Internals also check for flash/non-flash to select an appropriate copy func from newlib or rom (...or one internal memcmp that is case-insensitive). Methods previously missing length argument now try to utilize it internally and thus use string.h mem* funcs instead of str*

Also refactored some long standing weirdness w/ null-checks of source strings & buffer()s

resolve#9269

@gorlov-ai would you mind checking whether this fixes your code that crashed?
(preferably clone this whole tree, but c/p just the WString{.h,.cpp} files may also work)

allow *all* cstr method to use flash memory argumentsensure *all* cstr methods flow through same paths, avoid implicit String(cstr)throw out flashstringhelper method implementations in favour of cstr
consistent behaviour when accepting cstr input
expect empty cstr for simple methods, avoid doing it w/ length presentexpect {w,}buffer to be present, things are catastrophic anywaysalso, redundant wbuffer check for free()
introduce sys/ pgmspace.h, string.h and stdio.hconsistent signatures, avoid depending on newlib quirksallow strstr & strstr_P to be the same thing
wrappers expect length, thus no need to look for '\0'only missing piece is case-insensitive memcmp (memicmp?)since implementation requires it, manually do the tolower() loopupdate replace() w/o '\0' assumptions, always use mem rangesdrop strstr usage and reuse loop blocksalso returns actual len diff after comparison is otherwise equal
@mcsprmcsprforce-pushed thestring/cstr-pgmspace-funcs branch from979f9c0 to48f9fefCompareOctober 28, 2025 13:32
incorrectly using lastIndexOf, when should be using deduced search funcsince there is no reverse indexOf nor lastIndexOf allows end boundary,adjust buffer end pointer manually by swapping it w/ the found oneplus, reinit read ptr after possibly changing buffer() location
similar to replace() use, we already know there is nothing pastpreviously found needle ptr
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

In WString.cpp some of the methods access the insecure version of strcmp and strcnmp

1 participant

@mcspr

[8]ページ先頭

©2009-2025 Movatter.jp