Skip to content

Commit 12ba9de

Browse files
committed
Typos and whitespace cleanup
1 parent 1a04113 commit 12ba9de

File tree

14 files changed

+111
-110
lines changed

14 files changed

+111
-110
lines changed

src/android/app/src/main/java/org/gs1/gs1encodersapp/MainActivity.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class MainActivity : AppCompatActivity() {
133133
binding.syntaxTextBox.setText("Unbracketed AI element string")
134134
gs1encoder.dataStr = data
135135
} else if (data.startsWith("http://") || data.startsWith("https://")) {
136-
binding.syntaxTextBox.setText("Digital Link URI")
136+
binding.syntaxTextBox.setText("GS1 Digital Link URI")
137137
gs1encoder.dataStr = data
138138
} else if (data.matches("^\\d+$".toRegex())) {
139139
binding.syntaxTextBox.setText("Plain data")
@@ -182,12 +182,13 @@ class MainActivity : AppCompatActivity() {
182182
binding.errmsgTextInputLayout.visibility = View.VISIBLE
183183

184184
val markup = gs1encoder.errMarkup
185-
if (markup != "")
185+
if (markup != "") {
186186
binding.infoTextBox.setText(
187187
"AI content validation failed: " + markup.replace("|","")
188188
)
189189
binding.infoTextBox.visibility = View.VISIBLE
190190
binding.infoTextInputLayout.visibility = View.VISIBLE
191+
}
191192
return
192193
}
193194
else -> throw e

src/c-lib/ai.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* This library stores a compact representation of AI data (FNC1 in first) in
4848
* unbracketed format where "^" represents FNC1, i.e. "^..."
4949
*
50-
* Ingested AI element strings and Digital Link URI data is parsed then
50+
* Ingested AI element strings and GS1 Digital Link URI data is parsed then
5151
* processed (validated) into the aforementioned form. Either during parsing
5252
* or processing a table of extracted AIs is populated consisting of a pointer
5353
* to an AI table entry, as well as pointers to the start of the AI and its
@@ -65,13 +65,13 @@
6565
* been provided by the provided by the user, whether they have provided
6666
* bracketed AI data or scan data.
6767
*
68-
* Digital Link inputs are an exception since they must be stored as given,
69-
* ready to be encoded directly into a barcode symbol. Unlike conversion
70-
* between bracketed/unbracketed AI data and scan data, by specification the
71-
* conversion between Digital Link URIs and AI syntax is not bijective: the
72-
* URI stem is lost, element order may not be preserved and AI values may be
73-
* normalised into canonical form.
74-
68+
* GS1 Digital Link inputs are an exception since they must be stored as
69+
* given, ready to be encoded directly into a barcode symbol. Unlike
70+
* conversion between bracketed/unbracketed AI data and scan data, by
71+
* specification the conversion between GS1 Digital Link URIs and AI syntax is
72+
* not bijective: the URI stem is lost, element order may not be preserved and
73+
* AI values may be normalised into canonical form.
74+
*
7575
* The extracted AI element string is stored in dlAIbuffer which is used as
7676
* the storage for HRI text and construction bracketed AI strings.
7777
*

src/c-lib/gs1encoders-app.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ static bool userInt(gs1_encoder *ctx) {
5353

5454
printf("\n\n\nCurrent state:\n");
5555

56-
printf("\n Barcode message: %s\n", gs1_encoder_getDataStr(ctx));
57-
printf("\n AI element string: %s", gs1_encoder_getAIdataStr(ctx));
58-
printf("\n Digital Link URI: %s", gs1_encoder_getDLuri(ctx, NULL));
56+
printf("\n Barcode message: %s\n", gs1_encoder_getDataStr(ctx));
57+
printf("\n AI element string: %s", gs1_encoder_getAIdataStr(ctx));
58+
printf("\n GS1 Digital Link URI: %s", gs1_encoder_getDLuri(ctx, NULL));
5959
printf("\n HRI:\n");
6060
numHRI = gs1_encoder_getHRI(ctx, &hri);
6161
for (i = 0; i < numHRI; i++) {
@@ -66,7 +66,7 @@ static bool userInt(gs1_encoder *ctx) {
6666
printf("\n\n 1) Process raw barcode message data, either:");
6767
printf("\n * Plain data");
6868
printf("\n * Unbracketed AI element string with FNC1 in first position");
69-
printf("\n * Digital Link URI");
69+
printf("\n * GS1 Digital Link URI");
7070
printf("\n 2) Process a bracketed AI element string");
7171
printf("\n 3) Process barcode scan data (prefixed by AIM Symbology Identifier)");
7272

src/c-lib/gs1encoders.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ GS1_ENCODERS_API bool gs1_encoder_setDataStr(gs1_encoder *ctx, const char* dataS
204204

205205
// Validate and process data, including extraction of HRI
206206
ctx->numAIs = 0;
207-
if ((strlen(ctx->dataStr) >= 8 && strncmp(ctx->dataStr, "https://", 8) == 0) || // Digital Link URI
207+
if ((strlen(ctx->dataStr) >= 8 && strncmp(ctx->dataStr, "https://", 8) == 0) || // GS1 Digital Link URI
208208
(strlen(ctx->dataStr) >= 7 && strncmp(ctx->dataStr, "http://", 7) == 0)) {
209209
// We extract AIs with the element string stored in dlAIbuffer
210210
if (!gs1_parseDLuri(ctx, ctx->dataStr, ctx->dlAIbuffer))
@@ -819,7 +819,7 @@ void test_api_getHRI(void) {
819819
TEST_CHECK(strcmp(hri[1], "(10) ABC123") == 0);
820820
TEST_CHECK(strcmp(hri[2], "(99) COMPOSITE") == 0);
821821

822-
// HRI from Digital Link URI
822+
// HRI from GS1 Digital Link URI
823823
TEST_ASSERT(gs1_encoder_setDataStr(ctx, "https://a/01/12312312312333/22/TESTING?99=ABC%2d123&98=XYZ"));
824824
TEST_ASSERT((numAIs = gs1_encoder_getHRI(ctx, &hri)) == 4);
825825
TEST_ASSERT(hri != NULL);
@@ -828,7 +828,7 @@ void test_api_getHRI(void) {
828828
TEST_CHECK(strcmp(hri[2], "(99) ABC-123") == 0);
829829
TEST_CHECK(strcmp(hri[3], "(98) XYZ") == 0);
830830

831-
// HRI from Digital Link URI with extra ignored query params
831+
// HRI from GS1 Digital Link URI with extra ignored query params
832832
TEST_ASSERT(gs1_encoder_setDataStr(ctx, "https://a/01/12312312312333/22/TESTING?singleton&99=ABC%2d123&compound1=QWERTY&98=XYZ&compound2=12345"));
833833
TEST_ASSERT((numAIs = gs1_encoder_getHRI(ctx, &hri)) == 4);
834834
TEST_ASSERT(hri != NULL);

src/c-lib/scandata.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ bool gs1_processScanData(gs1_encoder* ctx, const char* scanData) {
616616
*p++ = '\\';
617617
strcpy(p, scanData);
618618

619-
// If a Digital Link URI is given then process it immediately
620-
if ((strlen(ctx->dataStr) >= 8 && strncmp(ctx->dataStr, "https://", 8) == 0) || // Digital Link URI
619+
// If a GS1 Digital Link URI is given then process it immediately
620+
if ((strlen(ctx->dataStr) >= 8 && strncmp(ctx->dataStr, "https://", 8) == 0) ||
621621
(strlen(ctx->dataStr) >= 7 && strncmp(ctx->dataStr, "http://", 7) == 0)) {
622622
// We extract AIs with the element string stored in dlAIbuffer
623623
if (!gs1_parseDLuri(ctx, ctx->dataStr, ctx->dlAIbuffer))
@@ -794,7 +794,7 @@ void test_scandata_processScanData(void) {
794794
test_testProcessScanData(true, "]Q3011231231231233310ABC123" "\x1D" "99TESTING",
795795
QR, "^011231231231233310ABC123^99TESTING");
796796

797-
// Digital Link URI
797+
// GS1 Digital Link URI
798798
test_testProcessScanData(true, "]Q1https://example.com/01/12312312312333?99=TEST",
799799
QR, "https://example.com/01/12312312312333?99=TEST");
800800
TEST_CHECK(strcmp(ctx->dlAIbuffer, "^011231231231233399TEST") == 0); // Check AI extraction
@@ -808,7 +808,7 @@ void test_scandata_processScanData(void) {
808808
test_testProcessScanData(true, "]d2011231231231233310ABC123" "\x1D" "99TESTING",
809809
DM, "^011231231231233310ABC123^99TESTING");
810810

811-
// Digital Link URI
811+
// GS1 Digital Link URI
812812
test_testProcessScanData(true, "]d1https://example.com/01/12312312312333?99=TEST",
813813
DM, "https://example.com/01/12312312312333?99=TEST");
814814
TEST_CHECK(strcmp(ctx->dlAIbuffer, "^011231231231233399TEST") == 0); // Check AI extraction

src/dotnet-app/MainWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void ProcessInputButton_Click(object sender, RoutedEventArgs e)
9999
}
100100
else if (inputTextBox.Text.StartsWith("http://") || inputTextBox.Text.StartsWith("https://"))
101101
{ // GS1 Digital Link URI
102-
syntaxTextBox.Text = "Digital Link URI";
102+
syntaxTextBox.Text = "GS1 Digital Link URI";
103103
App.gs1Encoder.DataStr = inputTextBox.Text;
104104
}
105105
else if (Regex.IsMatch(inputTextBox.Text, @"^\d+$"))

src/dotnet-lib/GS1Encoder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public string ErrMarkup
444444

445445

446446
/// <summary>
447-
/// Get a Digital Link URI that represents the AI-based input data.
447+
/// Get a GS1 Digital Link URI that represents the AI-based input data.
448448
///
449449
/// See the native library documentation for details:
450450
///

src/ios/GS1 Encoders App/ContentView.swift

+37-37
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ struct ContentView: View {
3333
@State var aiDataStr :String = ""
3434
@State var dlURI :String = ""
3535
@State var hri :String = ""
36-
36+
3737
@State var unknownAIs = false
3838
@State var associations = false
3939
@State var datatitles = false
40-
40+
4141
@FocusState var inputIsFocused: Bool
42-
42+
4343
let gs1encoder = try! GS1Encoder()
44-
44+
4545
init() {
46-
46+
4747
UIScrollView.appearance().bounces = false
48-
48+
4949
inputData = "https://example.com/01/12312312312333/10/ABC123?99=TESTING"
5050
libver = "GS1 Encoders library: " + gs1encoder.getVersion()
51-
51+
5252
}
53-
53+
5454
func clearRender() {
5555
syntax = ""
5656
dataStr = ""
@@ -62,7 +62,7 @@ struct ContentView: View {
6262
errorMsg = ""
6363
errorIsHidden = true
6464
}
65-
65+
6666
func loadDataValues() {
6767
unknownAIs = gs1encoder.getPermitUnknownAIs()
6868
associations = gs1encoder.getValidateAIassociations()
@@ -71,39 +71,39 @@ struct ContentView: View {
7171
if (gs1encoder.getDataStr() == "") {
7272
return
7373
}
74-
74+
7575
dataStr = gs1encoder.getDataStr()
76-
76+
7777
let ai = gs1encoder.getAIdataStr()
7878
aiDataStr = ai != "" ? ai : "⧚ Not AI-based data ⧛"
79-
79+
8080
do {
8181
dlURI = try gs1encoder.getDLuri()
8282
} catch GS1EncoderError.digitalLinkError(let msg) {
8383
dlURI = msg
8484
} catch {}
85-
85+
8686
hri = gs1encoder.getHRI().joined(separator: "\n")
87-
87+
8888
let qps = gs1encoder.getDLignoredQueryParams()
8989
if (qps.count > 0) {
9090
infoMsg = "Warning: Non-numeric query parameters ignored: ⧚" +
9191
qps.joined(separator: "&") + ""
9292
infoIsHidden = false
9393
}
9494
}
95-
95+
9696
func processInput() {
97-
97+
9898
clearRender()
99-
99+
100100
let data = inputData.trimmingCharacters(in: .whitespacesAndNewlines)
101101
if (data == "") {
102102
return
103103
}
104-
104+
105105
do {
106-
106+
107107
if (data.starts(with: "(")) {
108108
syntax = "Bracketed AI element string"
109109
try gs1encoder.setAIdataStr(data)
@@ -114,17 +114,17 @@ struct ContentView: View {
114114
syntax = "Unbracketed AI element string"
115115
try gs1encoder.setDataStr(data)
116116
} else if (data.starts(with: "http://") || data.starts(with: "https://")) {
117-
syntax = "Digital Link URI"
117+
syntax = "GS1 Digital Link URI"
118118
try gs1encoder.setDataStr(data)
119119
} else if (CharacterSet(charactersIn: data).isSubset(of: CharacterSet(charactersIn: "0123456789"))) {
120120
syntax = "Plain data"
121-
121+
122122
if (data.count != 8 && data.count != 12 && data.count != 13 && data.count != 14) {
123123
errorMsg = "Invalid length for a GTIN-8, GTIN-12, GTIN-13 or GTIN-14"
124124
errorIsHidden = false
125125
return
126126
}
127-
127+
128128
// Perform a checksum validation here, since the Syntax Engine validates only AI-based data
129129
var parity = 0
130130
var weight = data.count % 2 == 0 ? 3 : 1
@@ -133,23 +133,23 @@ struct ContentView: View {
133133
weight = 4 - weight
134134
}
135135
parity = (10 - parity % 10) % 10
136-
136+
137137
if (parity != data.last!.wholeNumberValue!) {
138138
errorMsg = "Incorrect numeric check digit"
139139
errorIsHidden = false
140140
infoMsg = "Plain data validation failed: " + data.dropLast() + "" + String(data.last!) + ""
141141
infoIsHidden = false
142142
return
143143
}
144-
144+
145145
syntax = "Plain GTIN-" + String(data.count) + " - converted to AI (01)..."
146146
try gs1encoder.setDataStr("^01" + String(repeating: "0", count: 14 - data.count) + data)
147-
147+
148148
} else {
149149
syntax = "Non-numeric plain data is not a valid GS1 syntax"
150150
return
151151
}
152-
152+
153153
} catch GS1EncoderError.parameterError(let msg),
154154
GS1EncoderError.scanDataError(let msg),
155155
GS1EncoderError.digitalLinkError(let msg) {
@@ -168,11 +168,11 @@ struct ContentView: View {
168168
}
169169

170170
inputIsFocused = false
171-
171+
172172
loadDataValues()
173-
173+
174174
}
175-
175+
176176
var body: some View {
177177
ScrollView() {
178178
VStack {
@@ -191,20 +191,20 @@ struct ContentView: View {
191191
try! gs1encoder.setIncludeDataTitlesInHRI(value)
192192
}
193193
}
194-
194+
195195
TextFieldWithBorder(label: "Input data", message: $inputData).focused($inputIsFocused).onChange(of: inputData) { value in
196196
clearRender()
197197
}
198-
198+
199199
Button {
200200
processInput()
201201
} label: {
202202
Text("PROCESS INPUT").frame(maxWidth: .infinity)
203203
}
204204
.buttonStyle(.borderedProminent)
205-
205+
206206
OutputView(errorMsg: $errorMsg, errorIsHidden: $errorIsHidden, infoMsg: $infoMsg, infoIsHidden: $infoIsHidden, syntax: $syntax, dataStr: $dataStr, aiDataStr: $aiDataStr, dlURI: $dlURI, hri: $hri)
207-
207+
208208
Spacer()
209209
}.onAppear(perform: loadDataValues)
210210
}
@@ -232,7 +232,7 @@ struct CheckboxToggleStyle: ToggleStyle {
232232
struct TextFieldWithBorder: View {
233233
var label :String
234234
@Binding var message :String
235-
235+
236236
var body: some View {
237237
ZStack(alignment: .topLeading) {
238238
TextField("", text: $message, axis: .vertical)
@@ -249,7 +249,7 @@ struct TextFieldWithBorder: View {
249249
}
250250

251251
struct OutputView: View {
252-
252+
253253
@Binding var errorMsg :String
254254
@Binding var errorIsHidden :Bool
255255
@Binding var infoMsg :String
@@ -259,7 +259,7 @@ struct OutputView: View {
259259
@Binding var aiDataStr :String
260260
@Binding var dlURI :String
261261
@Binding var hri :String
262-
262+
263263
var body: some View {
264264
if (!errorIsHidden) {
265265
TextFieldWithBorder(label: "Error", message: $errorMsg).disabled(true)
@@ -271,6 +271,6 @@ struct OutputView: View {
271271
TextFieldWithBorder(label: "Barcode message (^ = FNC1)", message: $dataStr).disabled(true)
272272
TextFieldWithBorder(label: "GS1 AI element string", message: $aiDataStr).disabled(true)
273273
TextFieldWithBorder(label: "GS1 Digital Link URI (canonical form)", message: $dlURI).disabled(true)
274-
TextFieldWithBorder(label: "HRI", message: $hri).disabled(true)
274+
TextFieldWithBorder(label: "HRI text", message: $hri).disabled(true)
275275
}
276276
}

0 commit comments

Comments
 (0)