MCPcopy Create free account
hub / github.com/crawl/crawl / _get_indent

Function _get_indent

crawl-ref/source/stringutil.cc:148–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147
148static const string _get_indent(const string &s)
149{
150 size_t prefix = 0;
151 if (starts_with(s, "\"") // ASCII quotes
152 || starts_with(s, "“") // English quotes
153 || starts_with(s, "„") // Polish/German/... quotes
154 || starts_with(s, "«") // French quotes
155 || starts_with(s, "»") // Danish/... quotes
156 || starts_with(s, "•")) // bulleted lists
157 {
158 prefix = 1;
159 }
160 else if (starts_with(s, "「")) // Chinese/Japanese quotes
161 prefix = 2;
162
163 size_t nspaces = s.find_first_not_of(' ', prefix);
164 if (nspaces == string::npos)
165 nspaces = 0;
166 if (!(prefix += nspaces))
167 return "";
168 return string(prefix, ' ');
169}
170
171
172// The provided string is consumed!

Callers 1

wordwrap_lineFunction · 0.85

Calls 1

starts_withFunction · 0.85

Tested by

no test coverage detected