@@ -135,7 +135,7 @@ type Bitfield struct {
135
135
136
136
func formatText (text string ) string {
137
137
text = regexp .MustCompile (`[ \t\n]+` ).ReplaceAllString (text , " " ) // Collapse whitespace (like in HTML)
138
- text = strings .Replace (text , "\\ n " , "\n " , - 1 )
138
+ text = strings .ReplaceAll (text , "\\ n " , "\n " )
139
139
text = strings .TrimSpace (text )
140
140
return text
141
141
}
@@ -273,9 +273,9 @@ func readSVD(path, sourceURL string) (*Device, error) {
273
273
p .Registers = append (p .Registers , parseRegister (regName , register , baseAddress , "" )... )
274
274
}
275
275
for _ , cluster := range periphEl .Clusters {
276
- clusterName := strings .Replace (cluster .Name , "[%s]" , "" , - 1 )
276
+ clusterName := strings .ReplaceAll (cluster .Name , "[%s]" , "" )
277
277
if cluster .DimIndex != nil {
278
- clusterName = strings .Replace (clusterName , "%s" , "" , - 1 )
278
+ clusterName = strings .ReplaceAll (clusterName , "%s" , "" )
279
279
}
280
280
clusterPrefix := clusterName + "_"
281
281
clusterOffset , err := strconv .ParseUint (cluster .AddressOffset , 0 , 32 )
@@ -292,7 +292,7 @@ func readSVD(path, sourceURL string) (*Device, error) {
292
292
}
293
293
// handle sub-clusters of registers
294
294
for _ , subClusterEl := range cluster .Clusters {
295
- subclusterName := strings .Replace (subClusterEl .Name , "[%s]" , "" , - 1 )
295
+ subclusterName := strings .ReplaceAll (subClusterEl .Name , "[%s]" , "" )
296
296
subclusterPrefix := subclusterName + "_"
297
297
subclusterOffset , err := strconv .ParseUint (subClusterEl .AddressOffset , 0 , 32 )
298
298
if err != nil {
@@ -414,7 +414,7 @@ func readSVD(path, sourceURL string) (*Device, error) {
414
414
// Properly format the license block, with comments.
415
415
licenseBlock := ""
416
416
if text := formatText (device .LicenseText ); text != "" {
417
- licenseBlock = "// " + strings .Replace (text , "\n " , "\n // " , - 1 )
417
+ licenseBlock = "// " + strings .ReplaceAll (text , "\n " , "\n // " )
418
418
licenseBlock = regexp .MustCompile (`\s+\n` ).ReplaceAllString (licenseBlock , "\n " )
419
419
}
420
420
@@ -595,7 +595,7 @@ func parseBitfields(groupName, regName string, fieldEls []*SVDField, bitfieldPre
595
595
if err != nil {
596
596
if enumBitSpecifier .MatchString (enumEl .Value ) {
597
597
// NXP SVDs use the form #xx1x, #x0xx, etc for values
598
- enumValue , err = strconv .ParseUint (strings .Replace (enumEl .Value [1 :], "x" , "0" , - 1 ), 2 , 32 )
598
+ enumValue , err = strconv .ParseUint (strings .ReplaceAll (enumEl .Value [1 :], "x" , "0" ), 2 , 32 )
599
599
if err != nil {
600
600
panic (err )
601
601
}
@@ -656,7 +656,7 @@ func NewRegister(element *SVDRegister, baseAddress uint64) *Register {
656
656
}
657
657
658
658
func (r * Register ) name () string {
659
- return strings .Replace (r .element .Name , "[%s]" , "" , - 1 )
659
+ return strings .ReplaceAll (r .element .Name , "[%s]" , "" )
660
660
}
661
661
662
662
func (r * Register ) description () string {
@@ -765,15 +765,15 @@ func parseRegister(groupName string, regEl *SVDRegister, baseAddress uint64, bit
765
765
for i , j := range reg .dimIndex () {
766
766
regAddress := reg .address () + (uint64 (i ) * dimIncrement )
767
767
results = append (results , & PeripheralField {
768
- Name : strings .ToUpper (strings .Replace (reg .name (), "%s" , j , - 1 )),
768
+ Name : strings .ToUpper (strings .ReplaceAll (reg .name (), "%s" , j )),
769
769
Address : regAddress ,
770
770
Description : reg .description (),
771
771
Array : - 1 ,
772
772
ElementSize : reg .size (),
773
773
})
774
774
}
775
775
// set first result bitfield
776
- shortName := strings .ToUpper (strings .Replace (strings .Replace (reg .name (), "_%s" , "" , - 1 ), "%s" , "" , - 1 ))
776
+ shortName := strings .ToUpper (strings .ReplaceAll (strings .ReplaceAll (reg .name (), "_%s" , "" ), "%s" , "" ))
777
777
results [0 ].Bitfields = parseBitfields (groupName , shortName , regEl .Fields , bitfieldPrefix )
778
778
return results
779
779
}
0 commit comments